Skip to content
Snippets Groups Projects
Commit 47c56a67 authored by Craig Tiller's avatar Craig Tiller
Browse files

A better benchmark diff script

parent 5adc93e0
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import sys import sys
import json import json
import bm_json import bm_json
import tabulate
with open(sys.argv[1]) as f: with open(sys.argv[1]) as f:
js_new_ctr = json.loads(f.read()) js_new_ctr = json.loads(f.read())
...@@ -21,8 +22,11 @@ for row in bm_json.expand_json(js_new_ctr, js_new_opt): ...@@ -21,8 +22,11 @@ for row in bm_json.expand_json(js_new_ctr, js_new_opt):
for row in bm_json.expand_json(js_old_ctr, js_old_opt): for row in bm_json.expand_json(js_old_ctr, js_old_opt):
old[row['cpp_name']] = row old[row['cpp_name']] = row
def changed_ratio(n, o):
return float(n-o)/float(o)
def min_change(pct): def min_change(pct):
return lambda n, o: abs((n-o)/o - 1) > pct/100 return lambda n, o: abs(changed_ratio(n,o)) > pct/100.0
_INTERESTING = ( _INTERESTING = (
('cpu_time', min_change(10)), ('cpu_time', min_change(10)),
...@@ -34,18 +38,36 @@ _INTERESTING = ( ...@@ -34,18 +38,36 @@ _INTERESTING = (
('atm_add_per_iteration', min_change(5)), ('atm_add_per_iteration', min_change(5)),
) )
changed = []
for fld, chk in _INTERESTING:
for bm in new.keys():
if bm not in old: continue
n = new[bm]
o = old[bm]
if fld not in n or fld not in o: continue
if chk(n[fld], o[fld]):
changed.append((fld, chk))
break
headers = ['Benchmark'] + [c[0] for c in changed] + ['Details']
rows = []
for bm in sorted(new.keys()): for bm in sorted(new.keys()):
if bm not in old: continue if bm not in old: continue
hdr = False row = [bm]
any_changed = False
n = new[bm] n = new[bm]
o = old[bm] o = old[bm]
print n details = ''
print o
for fld, chk in _INTERESTING: for fld, chk in _INTERESTING:
if fld not in n or fld not in o: continue if fld not in n or fld not in o: continue
if chk(n[fld], o[fld]): if chk(n[fld], o[fld]):
if not hdr: row.append(changed_ratio(n[fld], o[fld]))
print '%s shows changes:' % bm if details: details += ', '
hdr = True details += '%s:%r-->%r' % (fld, o[fld], n[fld])
print ' %s changed %r --> %r' % (fld, o[fld], n[fld]) any_changed = True
sys.exit(0) else:
row.append('')
if any_changed:
row.append(details)
rows.append(row)
print tabulate.tabulate(rows, headers=headers, floatfmt='+.2f')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment