-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconn_test.py
43 lines (33 loc) · 984 Bytes
/
conn_test.py
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
from thriftpool.remote.ThriftPool import Client
from thrift import Thrift
from thrift.protocol import TBinaryProtocol
from thrift.transport import TSocket, TTransport
import sys
import time
if sys.platform == 'win32':
_timer = time.clock
else:
_timer = time.time
host = "127.0.0.1"
port = 19097
delta = 5
# Init thrift connection and protocol handlers
transport = TSocket.TSocket(host, port)
transport = TTransport.TFramedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
# Set client to our Example
client = Client(protocol)
elapsed = 0
iterations = 1
while elapsed < delta:
iterations *= 2
t = _timer()
#transport.open()
for i in xrange(iterations):
transport.open()
client.echoString('test')
transport.close()
#transport.close()
elapsed = _timer() - t
print iterations, 'objects passed through connection in', elapsed, 'seconds'
print 'average number/sec:', iterations / elapsed