1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
12 using System
.Reflection
;
14 [assembly
: CLSCompliant(true)]
16 [assembly
: AssemblyTitle("IceLatencyClient")]
17 [assembly
: AssemblyDescription("Ice latency demo client")]
18 [assembly
: AssemblyCompany("ZeroC, Inc.")]
22 public class App
: Ice
.Application
24 public override int run(string[] args
)
28 Console
.Error
.WriteLine(appName() + ": too many arguments");
32 PingPrx ping
= PingPrxHelper
.checkedCast(communicator().propertyToProxy("Ping.Proxy"));
35 Console
.Error
.WriteLine("invalid proxy");
40 // A method needs to be invoked thousands of times before the JIT compiler
41 // will convert it to native code. To ensure an accurate latency measurement,
42 // we need to "warm up" the JIT compiler.
46 Console
.Error
.Write("warming up the JIT compiler...");
47 Console
.Error
.Flush();
48 for(int i
= 0; i
< reps
; i
++)
52 Console
.Error
.WriteLine("ok");
55 DateTime tv1
= DateTime
.Now
;
56 int repetitions
= 100000;
57 Console
.Out
.WriteLine("pinging server " + repetitions
+ " times (this may take a while)");
58 for (int i
= 0; i
< repetitions
; i
++)
63 double total
= (double)(DateTime
.Now
- tv1
).TotalMilliseconds
;
64 double perPing
= total
/ repetitions
;
66 Console
.Out
.WriteLine("time for " + repetitions
+ " pings: " + total
+ "ms");
67 Console
.Out
.WriteLine("time per ping: " + perPing
+ "ms");
73 public static int Main(string[] args
)
76 return app
.main(args
, "config.client");