forked from CowboyTim/python-storable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.py
More file actions
56 lines (47 loc) · 1.6 KB
/
Copy pathbenchmark.py
File metadata and controls
56 lines (47 loc) · 1.6 KB
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
52
53
54
55
56
#!/usr/bin/python
from time import time
import storable
def timethese(nr, methods):
print('Benchmark: timing '+str(nr)+' iterations of '+', '.join(methods.iterkeys())+'...')
for k,method in methods.iteritems():
start = time()
for i in range(0,nr):
method()
end = time()
print('%(abbr)15s : %(timing)7.2f wallclock secs @ %(speed).02f/s (n=%(nr)d)'\
%{'abbr' :k,\
'timing':(end - start),\
'speed' :(end - start)/nr,\
'nr' :nr})
def run():
fh = open("t/resources/x86_64-linux/2.18/050_complex06_2.18_x86_64-linux_nfreeze.storable", "rb")
small_data_nfreeze = fh.read()
fh.close()
fh = open("t/resources/x86_64-linux/2.18/049_complex06_2.18_x86_64-linux_freeze.storable", "rb")
small_data_freeze = fh.read()
fh.close()
fh = open("t/large_simple01_nfreeze.storable", "rb")
large_data_nfreeze = fh.read()
fh.close()
fh = open("t/large_simple01_freeze.storable", "rb")
large_data_freeze = fh.read()
fh.close()
timethese(100, {
'small_nfreeze' : lambda :storable.thaw(small_data_nfreeze),
'small_freeze' : lambda :storable.thaw(small_data_freeze ),
'large_nfreeze' : lambda :storable.thaw(large_data_nfreeze),
'large_freeze' : lambda :storable.thaw(large_data_freeze )
})
#import cProfile
#cProfile.run('run()')
# import threading
# tl = []
# for i in range(0,4):
# print("making thread:"+str(i))
# t = threading.Thread(target=run,args=())
# t.start()
# tl.append(t)
#
# for t in tl:
# t.join()
run()