-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspec-bisect.py
executable file
·35 lines (27 loc) · 1012 Bytes
/
spec-bisect.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
#!/usr/bin/env python3
import argparse
import sys
DESCR = 'Bisect SPEC benchmark run-time (parses .rsf tfile)'
parser = argparse.ArgumentParser(description=DESCR)
parser.add_argument('limit', type=float, help='Time limit in seconds')
parser.add_argument('-s', '--silent', action='store_true',
help='Do not print runspec/cpuspec output')
args = parser.parse_args()
rst = None
for line in sys.stdin:
if 'format: raw' in line:
assert not rst
rst = line.split()[-1]
if not args.silent:
print(line, end='')
print(f'Parsing {rst}')
lines = open(rst).read().splitlines()
reported = [line for line in lines if '.reported_time' in line]
assert len(reported) == 1
reported_time = float(reported[0].split()[-1])
fraction = 100.0 * reported_time / args.limit
print(f'SPEC run-time: {reported_time:.2f}s, limit: {args.limit:.2f}s '
f'({fraction:.2f}%)')
exit_code = 0 if reported_time <= args.limit else 1
print(f'Exit code: {exit_code}')
sys.exit(exit_code)