forked from statsite/statsite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.py
More file actions
31 lines (25 loc) · 646 Bytes
/
bench.py
File metadata and controls
31 lines (25 loc) · 646 Bytes
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
import socket
import time
import random
NUM = 1024 * 1024
KEYS = ["test", "foobar", "zipzap"]
VALS = [32, 100, 82, 101, 5, 6, 42, 73]
METS = []
for x in xrange(NUM):
key = random.choice(KEYS)
val = random.choice(VALS)
METS.append("%s:%f|c\n" % (key, val))
s = socket.socket()
s.connect(("localhost", 8125))
start = time.time()
total = 0
while True:
current = 0
while current < len(METS):
msg = "".join(METS[current:current + 1024])
current += 1024
total += 1024
s.sendall(msg)
diff = time.time() - start
ops_s = total / diff
print "%0.2f sec\t - %.0f ops/sec" % (diff, ops_s)