-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtester.py
71 lines (62 loc) · 1.63 KB
/
tester.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import subprocess
import pandas as pd
TESTCASE_DIR = './testcases/'
TESTCASE_NAMES = [
'array_test1', 'array_test2', 'basicopt1', 'bulgarian', 'expr', 'gcd',
'hanoi', 'lvalue2', 'magic', 'manyarguments', 'multiarray', 'naive',
'pi', 'qsort', 'queens', 'statement_test', 'superloop', 'tak'
]
ALU_NUM = [2, 4]
PREDICTORS = [
'twobit', 'local', 'gshare', 'tournament'
]
def construct_cmd(test_name, alun, pred_name):
return ' '.join([
'.\\code.exe',
TESTCASE_DIR + test_name + '.data',
'-A', str(alun),
'-P', pred_name, '10',
'-stat'
])
names = []
preds = []
alus = []
result = []
cycles = []
p00 = []
p01 = []
p10 = []
p11 = []
for name in TESTCASE_NAMES:
for alun in ALU_NUM:
for pred in PREDICTORS:
cmd = construct_cmd(name, alun, pred)
print('running:', cmd)
p = subprocess.run(cmd, shell= True, stdout= subprocess.PIPE)
s = p.stdout.decode('gbk')
ls = s.split('\n')
names.append(name)
preds.append(pred)
alus.append(alun)
result.append(int(ls[0]))
cycles.append(int(ls[1]))
ll = ls[2].split('\t')
p00.append(int(ll[0]))
p01.append(int(ll[1]))
ll = ls[3].split('\t')
p10.append(int(ll[0]))
p11.append(int(ll[1]))
df = pd.DataFrame(
{
'name': names,
'predictor': preds,
'alun': alus,
'result': result,
'cycle': cycles,
'P00': p00,
'P01': p01,
'P10': p10,
'P11': p11,
}
)
df.to_csv('./illustration/result.csv')