diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-09-04 14:51:31 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-09-04 14:51:31 +0000 |
commit | 3ef447033e4b5b97e9ac52eda57f969072fd8ddc (patch) | |
tree | 8bac601c1ea7175695a71ba14924b62c77f40b49 /py/demo/Ice/latency/Client.py | |
parent | eliminating duplicate functions in Util and PythonUtil (diff) | |
download | ice-3ef447033e4b5b97e9ac52eda57f969072fd8ddc.tar.bz2 ice-3ef447033e4b5b97e9ac52eda57f969072fd8ddc.tar.xz ice-3ef447033e4b5b97e9ac52eda57f969072fd8ddc.zip |
initial check-in
Diffstat (limited to 'py/demo/Ice/latency/Client.py')
-rw-r--r-- | py/demo/Ice/latency/Client.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/py/demo/Ice/latency/Client.py b/py/demo/Ice/latency/Client.py new file mode 100644 index 00000000000..40d8b6e3f57 --- /dev/null +++ b/py/demo/Ice/latency/Client.py @@ -0,0 +1,68 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, time, Ice + +Ice.loadSlice('Latency.ice') +import Demo + +def run(args, communicator): + properties = communicator.getProperties() + proxy = properties.getProperty('Latency.Ping') + if len(proxy) == 0: + print " property `Latency.Ping' not set" + return False + + base = communicator.stringToProxy(proxy) + ping = Demo.PingPrx.checkedCast(base) + if not ping: + print "invalid proxy" + return False + + # Initial ping to setup the connection. + ping.ice_ping(); + + repetitions = 100000 + print "pinging server " + str(repetitions) + " times (this may take a while)" + + tsec = time.time() + + i = repetitions + while(i >= 0): + ping.ice_ping() + i = i - 1 + + tsec = time.time() - tsec + tmsec = tsec * 1000.0 + + print "time for %d pings: %.3fms" % (repetitions, tmsec) + print "time per ping: %.3fms" % (tmsec / repetitions) + + return True + +try: + properties = Ice.createProperties() + properties.load("config") + communicator = Ice.initializeWithProperties(sys.argv, properties) + status = run(sys.argv, communicator) +except Ice.Exception, ex: + print ex + status = False + +if communicator: + try: + communicator.destroy() + except Ice.Exception, ex: + print ex + status = False + +if status: + sys.exit(0) +else: + sys.exit(1) |