summaryrefslogtreecommitdiff
path: root/py/demo/Ice/latency/Client.py
blob: 0d4b2d0dcc45d1358518d442d2551ce55e84fca9 (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
#!/usr/bin/env python
# **********************************************************************
#
# Copyright (c) 2003-2015 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):
        if len(args) > 1:
            print(self.appName() + ": too many arguments")
            return 1

        ping = Demo.PingPrx.checkedCast(self.communicator().propertyToProxy('Ping.Proxy'))
        if not ping:
            print("invalid proxy")
            return 1

        # 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 0

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