File: connections.py

package info (click to toggle)
pyro4 4.82-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 2,528 kB
  • sloc: python: 17,736; makefile: 169; sh: 113; javascript: 62
file content (49 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (3)
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
from __future__ import print_function
import time
import sys

import Pyro4


if sys.version_info < (3, 0):
    input = raw_input

uri = input("Uri of benchmark server? ").strip()

print("Timing raw connect speed (no method call)...")
p = Pyro4.core.Proxy(uri)
p.oneway()
ITERATIONS = 2000
begin = time.time()
for loop in range(ITERATIONS):
    if loop % 500 == 0:
        print(loop)
    p._pyroRelease()
    p._pyroBind()
duration = time.time() - begin
print("%d connections in %.3f sec = %.0f conn/sec" % (ITERATIONS, duration, ITERATIONS / duration))
del p

print("Timing proxy creation+connect+methodcall speed...")
ITERATIONS = 2000
begin = time.time()
for loop in range(ITERATIONS):
    if loop % 500 == 0:
        print(loop)
    with Pyro4.core.Proxy(uri) as p:
        p.oneway()
duration = time.time() - begin
print("%d new proxy calls in %.3f sec = %.0f calls/sec" % (ITERATIONS, duration, ITERATIONS / duration))

print("Timing proxy methodcall speed...")
p = Pyro4.core.Proxy(uri)
p.oneway()
ITERATIONS = 10000
begin = time.time()
for loop in range(ITERATIONS):
    if loop % 1000 == 0:
        print(loop)
    p.oneway()
duration = time.time() - begin
print("%d calls in %.3f sec = %.0f calls/sec" % (ITERATIONS, duration, ITERATIONS / duration))
print("Serializer used:", Pyro4.config.SERIALIZER)