-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiming.py
49 lines (45 loc) · 1.64 KB
/
timing.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
"""
Measure timing of satyrs on cnf files of varying sizes.
"""
from subprocess import check_output, STDOUT
from numpy import std
# In (roughly) increasing order
CNF_FILES = [
'./tests/test.cnf',
'./tests/quinn.cnf',
'./tests/medium.cnf',
'./tests/cascade.cnf',
#Unsat
'./tests/phole/hole6.cnf',
'./tests/phole/hole7.cnf'
# './tests/dubois29_unsat.cnf'
]
if __name__ == '__main__':
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('-n', '--num', type=int, default=5,
help="Number of times to run satyrs on each cnf")
parser.add_argument('-v', '--verbose', action='store_true',
help="Be verbose (print the results of each run)")
args = parser.parse_args()
for f in CNF_FILES:
average_time = 0
runs = []
for i in xrange(args.num):
output = check_output(
["time","target/debug/satyrs", f],
stderr=STDOUT,
)
# Output from time command is the last six elements of this
# split, and real time is what we're looking for
#print output
timing_output = output.split()[-6:]
real_time = float(timing_output[0])
if args.verbose:
print "{} ({}): {}".format(f, i, real_time)
average_time += real_time / args.num
runs.append(real_time)
print "{} (AVERAGE): {}\n\t(min: {} max: {} sd: {})".format(
f, average_time, round(min(runs), 2),
round(max(runs), 2), round(std(runs), 2)
)