forked from fract4d/gnofract4d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchfct.py
executable file
·45 lines (38 loc) · 1.02 KB
/
benchfct.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
#!/usr/bin/env python
import sys
import os
from time import time as now
class Benchmark:
def __init__(self, command, args):
self.last_time = None
self.pos = 0
self.args = args
self.command = command
def build(self):
cmd = self.command + " --buildonly foo.so " + self.args
print(cmd)
result = os.system(cmd)
assert result == 0
def run(self):
last_time = now()
result = os.system(self.command + " --usebuilt ./foo.so " + self.args)
assert result == 0
new_time = now()
return new_time - last_time
repeats = 1
command = "./gnofract4d -i 2560 -j 2048 --nogui "
args = ""
for arg in sys.argv[1:]:
if arg == "--repeat":
repeats = 5
else:
args += " " + arg
bench = Benchmark(command, args)
bench.build()
times = []
for i in range(repeats):
t = bench.run()
print(t)
times.append(t)
print("stats")
print("min:(%.4f), max(%.4f), average(%.4f)" % (min(times), max(times), sum(times)/len(times)))