-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbenchmark.py
More file actions
58 lines (46 loc) · 1.6 KB
/
benchmark.py
File metadata and controls
58 lines (46 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
57
58
#!/usr/bin/python
from time import time
import storable
def timethese(nr, methods):
print('Benchmark: timing {} iterations of {}...'.format(
nr, ', '.join(methods)))
for k, method in methods.items():
start = time()
for i in range(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():
with open("tests/resources/x86_64-linux/2.18/025_complex06_2.18_x86_64-linux_nfreeze.storable", "rb") as fh:
small_data_nfreeze = fh.read()
with open("tests/resources/x86_64-linux/2.18/025_complex06_2.18_x86_64-linux_freeze.storable", "rb") as fh:
small_data_freeze = fh.read()
with open("tests/large_simple01_nfreeze.storable", "rb") as fh:
large_data_nfreeze = fh.read()
with open("tests/large_simple01_freeze.storable", "rb") as fh:
large_data_freeze = fh.read()
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()