summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CSharp/Ivy/IvyPerf/IvyPerf.cs21
1 files changed, 14 insertions, 7 deletions
diff --git a/CSharp/Ivy/IvyPerf/IvyPerf.cs b/CSharp/Ivy/IvyPerf/IvyPerf.cs
index 1351318..db3302e 100644
--- a/CSharp/Ivy/IvyPerf/IvyPerf.cs
+++ b/CSharp/Ivy/IvyPerf/IvyPerf.cs
@@ -12,6 +12,7 @@ namespace IvyPerf
class IvyPerf
{
static Ivy bus;
+ static double origin = 0;
static double currentTime() // en ms
{
@@ -23,17 +24,18 @@ namespace IvyPerf
[IvyBinding("^ping ts=(.*)")]
static void Reply(IvyClient client, string[] args)
{
- bus.sendMsg("pong ts={0} tr={1}", args[0], currentTime());
+ bus.sendMsg("pong ts={0} tr={1}", args[0], currentTime() - origin );
}
[IvyBinding("^pong ts=(.*) tr=(.*)")]
static void Pong(IvyClient client, string[] args)
{
- double current = currentTime();
+ double current = currentTime() - origin;
double ts = double.Parse( args[0], bus.Culture );
double tr = double.Parse(args[1], bus.Culture );
- double roundtrip1 = tr-ts;
- double roundtrip2 = current - ts;
- Console.WriteLine( "round trip {0} {1}", roundtrip1 , roundtrip2 );
+ double roundtrip1 = tr - ts;
+ double roundtrip2 = current - tr;
+ double roundtrip3 = current - ts;
+ Console.WriteLine("round trip {0} {1} {2}", roundtrip1, roundtrip2, roundtrip3);
}
/// <summary>
/// Point d'entrée principal de l'application.
@@ -41,18 +43,23 @@ namespace IvyPerf
[STAThread]
static void Main(string[] args)
{
+ int timeout = 1000;
+ if (args.Length > 0)
+ timeout = int.Parse(args[0]);
StringCollection my_messsages = new StringCollection();
my_messsages.Add("ping");
my_messsages.Add("pong");
+ my_messsages.Add("IvyPref");
bus = new Ivy("IvyPerf", "IvyPref ready");
bus.BindingFilter += new Ivy.ClientRemoveBindingHandler(bus_BindingFilter);
bus.SentMessageClasses = my_messsages;
bus.AutoBinding(typeof(IvyPerf));
bus.start(null);
+ origin = currentTime();
while( true )
{
- Thread.Sleep( 1000 );
- int count = bus.sendMsg("ping ts={0}", currentTime());
+ Thread.Sleep( timeout );
+ int count = bus.sendMsg("ping ts={0}", currentTime() - origin );
if ( count == 0 ) Console.Write( "." );
}
}