summaryrefslogtreecommitdiff
path: root/py/demo/Ice/latency/Client.py
blob: fd6cf0b705ecf5a166265c29cfb6aa77fd2a694b (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2007 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, traceback, Ice

Ice.loadSlice('Latency.ice')
import Demo

class Client(Ice.Application):
    def run(self, args):
        ping = Demo.PingPrx.checkedCast(self.communicator().propertyToProxy('Latency.Ping'))
        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

app = Client()
sys.exit(app.main(sys.argv, "config.client"))