-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval.py
executable file
·108 lines (89 loc) · 3 KB
/
eval.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/python3
import os
import sys
import subprocess
class RPythonError(Exception):
def __init__(self, msg):
assert isinstance(msg, str)
self.msg = msg
def time_cmd(args):
p = subprocess.Popen(['/usr/bin/time', '-f%U'] + args, cwd='b/',
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
timing = p.stderr.read().strip()
sys.stderr.write(p.stdout.read().decode('utf-8').split('\n')[-1])
#assert p.returncode == 0, p.returncode
try:
user = float(timing)
except ValueError:
raise RPythonError(timing.decode('utf-8'))
cmd = ' '.join(args)
sys.stderr.write(" ".join(args) + " => " + str(user) + "\n")
sys.stderr.flush()
#print('time {cmd} --> {user}s'.format(**locals()))
return user
def mean(numbers):
return float(sum(numbers)) / max(len(numbers), 1)
def benchmark(exe, args, benchmark, extra):
return mean([
time_cmd([exe] + args + [benchmark] + extra) for i in range(1 if TEST else 3)
])
def please(which, bench, *extra):
options, ext = executables[which]
args = options.split(' ')
exe = args.pop(0)
name = bench + ext
if 'nfs' in exe:
assert os.path.exists(os.path.join('b/', name)), name
# name, bench, options, result, max, min
average = benchmark(exe, args, name, list(extra))
print(",".join((which, bench, " ".join(extra), "%.3f" % average)))
sys.stdout.flush()
#, str(maxval), str(minval))))
benchmarks = [
('spectralnorm', 5500),
('fibm', 40, 1000000),
('nbody', 5000000),
('binary', 20),
#('fibiter', 40),
('fibiter2', 40),
('fibm', 40, 1000000),
]
benchmarks2 = [
('binary', 12),
('fibiter2', 31),
('fibm', 40, 1000000),
('nbody', 500000),
('spectralnorm', 550),
]
test_benchmarks = [
('spectralnorm', 550),
('fibm', 40, 1000000),
('nbody', 200000),
('spectralnorm', 550),
('binary', 10),
#('fibiter', 30),
('fibiter2', 30),
('fibm', 40, 100000),
]
executables = dict(
nfs = ('../nefarious/nfs-74f3e92 --noinline', '.nfs'),
nfs_jit = ('../nefarious/nfsj-74f3e92 --noinline', '.nfs'),
nfs_inline = ('../nefarious/nfs-74f3e92', '.nfs'),
nfs_jit_inline = ('../nefarious/nfsj-74f3e92', '.nfs'),
nfs_inlineinf = ('../nefarious/nfs-a059656', '.nfs'),
nfs_jit_inlineinf = ('../nefarious/nfsj-a059656', '.nfs'),
nfs_inline80 = ('../nefarious/nfs-d320827', '.nfs'),
nfs_jit_inline80 = ('../nefarious/nfsj-d320827', '.nfs'),
#python = ('python2', '.py'),
#java = ('java', ''),
#nfs_parse = ('../nefarious/nfs-74f3e92 --parse', '.nfs'),
)
TEST = 'test' in sys.argv
#_, which, bench, *extra = sys.argv
#please(which, bench, *extra)
for which in ('nfs_jit',): #'nfs_jit_inline80', 'nfs_inline80': #sorted(executables.keys(), key=len, reverse=True):
print(which, file=sys.stderr)
for bench, *args in (test_benchmarks if TEST else benchmarks):
please(which, bench, *[str(x) for x in args])
print(file=sys.stderr)
print('='*40, file=sys.stderr)