blob: a4e9e7113dda98f70a3f70c22aca612dda42f48f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// **********************************************************************
//
// Copyright (c) 2001
// Mutable Realms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************
public class Client
{
private static int
run(String[] args, Ice.Communicator communicator)
{
Ice.Properties properties = communicator.getProperties();
final String refProperty = "Latency.Ping";
String ref = properties.getProperty(refProperty);
if(ref.length() == 0)
{
System.err.println("property `" + refProperty + "' not set");
return 1;
}
Ice.ObjectPrx base = communicator.stringToProxy(ref);
PingPrx ping = PingPrxHelper.checkedCast(base);
if(ping == null)
{
System.err.println("invalid object reference");
return 1;
}
// Initial ping to setup the connection.
ping.ice_ping();
long tv1 = System.currentTimeMillis();
final int repetitions = 100000;
System.out.println("pinging server " + repetitions + " times (this may take a while)");
for(int i = 0; i < repetitions; i++)
{
ping.ice_ping();
}
long tv2 = System.currentTimeMillis();
double total = (double)(tv2 - tv1);
double perPing = total / repetitions;
System.out.println("time for " + repetitions + " pings: " + total + "ms");
System.out.println("time per ping: " + perPing + "ms");
return 0;
}
public static void
main(String[] args)
{
int status = 0;
Ice.Communicator communicator = null;
try
{
Ice.Properties properties = Ice.Util.createProperties(args);
properties.load("config");
communicator = Ice.Util.initializeWithProperties(args, properties);
status = run(args, communicator);
}
catch(Ice.LocalException ex)
{
ex.printStackTrace();
status = 1;
}
if(communicator != null)
{
try
{
communicator.destroy();
}
catch(Ice.LocalException ex)
{
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
|