-
Notifications
You must be signed in to change notification settings - Fork 215
/
Copy pathclient.rb
executable file
·46 lines (34 loc) · 974 Bytes
/
client.rb
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
#!/usr/bin/env ruby
#
# Copyright (c) ZeroC, Inc. All rights reserved.
#
require 'Ice'
Ice::loadSlice('Latency.ice')
def run(communicator, args)
if args.length > 0
puts $0 + ": too many argumnets"
return 1
end
ping = Demo::PingPrx::checkedCast(communicator.propertyToProxy('Ping.Proxy'))
if not ping
puts "invalid proxy"
return 1
end
# Initial ping to setup the connection.
ping.ice_ping()
repetitions = 100000
puts "pinging server " + repetitions.to_s + " times (this may take a while)"
tsec = Time.now
i = repetitions
while i >= 0
ping.ice_ping()
i = i - 1
end
tsec = Time.now - tsec
tmsec = tsec * 1000.0
printf "time for %d pings: %.3fms\n", repetitions, tmsec
printf "time per ping: %.3fms\n", tmsec / repetitions
return 0
end
status = Ice::initialize(ARGV, "config.client") { |communicator, args| run(communicator, args) }
exit(status)