summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2007-02-01 10:04:45 +0000
committerfcolin2007-02-01 10:04:45 +0000
commitea6f209aa905e5f9f64b469d0b22fb8a3b6e6f39 (patch)
tree162efd4ec831385a8f3d1ea1debcd3e3d10c6729
parentbb505ecd2b3485a2548ed678fe09b5d7401e4fcb (diff)
downloadivy-csharp-ea6f209aa905e5f9f64b469d0b22fb8a3b6e6f39.zip
ivy-csharp-ea6f209aa905e5f9f64b469d0b22fb8a3b6e6f39.tar.gz
ivy-csharp-ea6f209aa905e5f9f64b469d0b22fb8a3b6e6f39.tar.bz2
ivy-csharp-ea6f209aa905e5f9f64b469d0b22fb8a3b6e6f39.tar.xz
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)
-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( "." );
}
}