-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbench_worker.py
More file actions
executable file
·70 lines (52 loc) · 1.66 KB
/
bench_worker.py
File metadata and controls
executable file
·70 lines (52 loc) · 1.66 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
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python2.6 -W ignore
import sys
import os
import re
TEMP_TIME_LOG = 'tmp_bench_time.log'
TEMP_PROF_LOG = 'tmp_bench_prof.log'
TIME_ARG = '/usr/bin/time -f "%e;%M" -o "'+TEMP_TIME_LOG+'" '
def opts(argv):
params = {}
params['execution_times'] = int(argv[1])
params['log_file'] = argv[2]
params['custom_col'] = argv[3]
params['custom_val'] = float(argv[4])
params['arg'] = argv[5]
return params
def do_benchmark(arguments):
print TIME_ARG, ' vote_count ', arguments
os.system(TIME_ARG+' vote_count '+arguments+' > '+TEMP_PROF_LOG)
pass
def accumulate_data(custom_val):
# data : custom_col, time, memory, CPU/IO ratio, thread time, mutex call times
data = []
f = open(TEMP_TIME_LOG, 'r')
t = f.read().split('\n')[0].split(';')
print t
data.append(custom_val)
data.append(float(t[0]))
data.append(int(t[1]))
f.close()
f = open(TEMP_PROF_LOG, 'r')
prof = f.read().split('\n')[0].split(',')
print prof
io_time = float(prof[0]);
mutex_call = int(prof[1]);
average_mutex_time = float(prof[2]);
data.append(io_time)
data.append(mutex_call)
data.append(average_mutex_time)
return data
def main(argv):
params = opts(argv)
f = open(params['log_file'], 'aw')
#f.write(params['custom_col']+', time, memory, ratio, thread, mutex\n')
for i in range(0, params['execution_times']):
do_benchmark(params['arg'])
data = accumulate_data(params['custom_val'])
print data
f.write(str(data).replace('[','').replace(']',''))
f.write('\n')
f.close()
if __name__ == '__main__':
main(sys.argv)