-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduce.py
50 lines (43 loc) · 1.4 KB
/
produce.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
from subprocess import PIPE
import subprocess
import sys
import json
def get_float(target):
out = target.replace('\n', '')
return float(out)
if(len(sys.argv) != 6):
print('wrong usage: python ', sys.argv[0], ' executableName ', 'inputFileName', 'outputFileName', 'fileResultName', 'numExecution')
exit(-1)
executableName = sys.argv[1]
exInputFilename = sys.argv[2]
exOnputFilename = sys.argv[3]
outFilename = sys.argv[4]
n_ex = int(sys.argv[5])
nws = [2, 4, 8, 16, 32, 64, 96, 128, 192, 256]
ks = [5, 50, 100]
times = {}
time = 0.0
if executableName == 'sequential':
k_dict = {}
for k in ks:
time = 0.0
for ex in range(n_ex):
result = subprocess.check_output(["./sequential", str(k), exInputFilename,exOnputFilename], universal_newlines=True)
curr_time = get_float(result)
time += curr_time
k_dict[k] = time / n_ex
times[-1] = k_dict
else:
for nw in nws:
k_dict = {}
for k in ks:
time = 0.0
for ex in range(n_ex):
result = subprocess.check_output(["./"+executableName, str(k), str(nw), exInputFilename,
exOnputFilename], universal_newlines=True)
c_time = get_float(result)
time += c_time
k_dict[k] = time / n_ex
times[nw] = k_dict
with open(outFilename, 'w+') as fp:
json.dump(times, fp, indent=4)