forked from lcls-psana/pscache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_performance.py
53 lines (39 loc) · 1.1 KB
/
test_performance.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
44
45
46
47
48
49
50
51
from pscache import publisher
from pscache import client
import time
import numpy as np
import redis
import socket
if socket.gethostname()[:5] == 'psana':
print 'psana machine, using psdb3 as REDIS target'
HOST = 'psdb3'
else:
HOST = 'localhost'
PORT = 6379
DB = 0
# setup
pub = publisher.ExptPublisher('testexpt', host=HOST)
cli = client.ExptClient('testexpt', host=HOST)
run = 1
key = 'testdata'
cli.delete_run(run)
data_sizes = [(100000,), (100,100,100), (1,100000)]
print "------ TESTING REDIS PERFORMANCE ------"
print "HOST: %s" % HOST
print ""
print ">>> testing publisher"
for i,ds in enumerate(data_sizes):
data = np.random.randn(*ds)
t0 = time.time()
pub._send_data(run, key+str(i), data, event_limit=-1)
t1 = time.time()
print " %s ::\t%.3f sec" % (str(ds), t1-t0)
print ">>> testing client"
for i,ds in enumerate(data_sizes):
data = np.random.randn(*ds)
t0 = time.time()
data = cli.fetch_data(run, keys=[key+str(i),])
t1 = time.time()
print " %s ::\t%.3f sec" % (str(ds), t1-t0)
assert data[key+str(i)].shape == ds
cli.delete_run(run)