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

Fix EINTR forever

parent c2d9f1e2
No related branches found
No related tags found
No related merge requests found
...@@ -192,52 +192,59 @@ class Benchmark: ...@@ -192,52 +192,59 @@ class Benchmark:
return [self.final[f] if f in self.final else '' for f in flds] return [self.final[f] if f in self.final else '' for f in flds]
def read_file(filename): def eintr_be_gone(fn):
"""Run fn until it doesn't stop because of EINTR"""
while True: while True:
try: try:
with open(filename) as f: return fn()
return f.read()
except IOError, e: except IOError, e:
if e.errno != errno.EINTR: if e.errno != errno.EINTR:
raise raise
def read_json(filename): def read_json(filename):
return json.loads(read_file(filename)) with open(filename) as f: return json.loads(f.read())
benchmarks = collections.defaultdict(Benchmark)
def finalize():
for bm in args.benchmarks: benchmarks = collections.defaultdict(Benchmark)
for loop in range(0, args.loops):
js_new_ctr = read_json('%s.counters.new.%d.json' % (bm, loop)) for bm in args.benchmarks:
js_new_opt = read_json('%s.opt.new.%d.json' % (bm, loop)) for loop in range(0, args.loops):
js_old_ctr = read_json('%s.counters.old.%d.json' % (bm, loop)) js_new_ctr = read_json('%s.counters.new.%d.json' % (bm, loop))
js_old_opt = read_json('%s.opt.old.%d.json' % (bm, loop)) js_new_opt = read_json('%s.opt.new.%d.json' % (bm, loop))
js_old_ctr = read_json('%s.counters.old.%d.json' % (bm, loop))
for row in bm_json.expand_json(js_new_ctr, js_new_opt): js_old_opt = read_json('%s.opt.old.%d.json' % (bm, loop))
print row
name = row['cpp_name'] for row in bm_json.expand_json(js_new_ctr, js_new_opt):
if name.endswith('_mean') or name.endswith('_stddev'): continue print row
benchmarks[name].add_sample(row, True) name = row['cpp_name']
for row in bm_json.expand_json(js_old_ctr, js_old_opt): if name.endswith('_mean') or name.endswith('_stddev'): continue
print row benchmarks[name].add_sample(row, True)
name = row['cpp_name'] for row in bm_json.expand_json(js_old_ctr, js_old_opt):
if name.endswith('_mean') or name.endswith('_stddev'): continue print row
benchmarks[name].add_sample(row, False) name = row['cpp_name']
if name.endswith('_mean') or name.endswith('_stddev'): continue
really_interesting = set() benchmarks[name].add_sample(row, False)
for name, bm in benchmarks.items():
print name really_interesting = set()
really_interesting.update(bm.process()) for name, bm in benchmarks.items():
fields = [f for f in args.track if f in really_interesting] print name
really_interesting.update(bm.process())
headers = ['Benchmark'] + fields fields = [f for f in args.track if f in really_interesting]
rows = []
for name in sorted(benchmarks.keys()): headers = ['Benchmark'] + fields
if benchmarks[name].skip(): continue rows = []
rows.append([name] + benchmarks[name].row(fields)) for name in sorted(benchmarks.keys()):
if rows: if benchmarks[name].skip(): continue
text = 'Performance differences noted:\n' + tabulate.tabulate(rows, headers=headers, floatfmt='+.2f') rows.append([name] + benchmarks[name].row(fields))
else: if rows:
text = 'No significant performance differences' text = 'Performance differences noted:\n' + tabulate.tabulate(rows, headers=headers, floatfmt='+.2f')
comment_on_pr.comment_on_pr('```\n%s\n```' % text) else:
print text text = 'No significant performance differences'
comment_on_pr.comment_on_pr('```\n%s\n```' % text)
print text
eintr_be_gone(finalize)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment