From ea6f209aa905e5f9f64b469d0b22fb8a3b6e6f39 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 10:04:45 +0000 Subject: Utilisateur : Fcolin Date : 20/04/06 Heure : 14:00 Archivé dans $/CSharp/Ivy/IvyPerf Commentaire: mise au point timer , ca manque de precision !!! (vss 8) --- CSharp/Ivy/IvyPerf/IvyPerf.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'CSharp/Ivy') 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); } /// /// 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( "." ); } } -- cgit v1.1