Created
May 8, 2020 15:16
-
-
Save Mytherin/e784a816118e58d9c7220bd763c5c06e to your computer and use it in GitHub Desktop.
Format Benchmarks as Markdown Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
benchmarks = {} | |
def flush_benchmark(fname, benchmark, times): | |
if benchmark == None: | |
return | |
benchmarks[fname][benchmark] = numpy.mean(times) | |
benchmark = None | |
times = [] | |
fnames = ['nojemalloc', 'jemalloc'] | |
benchmark_names = [] | |
for fname in fnames: | |
benchmarks[fname] = {} | |
with open(fname, 'r') as f: | |
benchmark = None | |
times = [] | |
for line in f: | |
if '||' in line: | |
flush_benchmark(fname, benchmark, times) | |
benchmark = line.split('||')[1].strip() | |
if benchmark not in benchmark_names: | |
benchmark_names.append(benchmark) | |
times = [] | |
if '...' in line: | |
try: | |
val = float(line.split('...')[1].strip()) | |
times.append(val) | |
except: | |
pass | |
flush_benchmark(fname, benchmark, times) | |
benchmark_names.sort() | |
print('| Query | System | Jemalloc |Speedup|') | |
print('|:------|-------:|---------:|------:|') | |
for bname in benchmark_names: | |
nojeval = benchmarks['nojemalloc'][bname] | |
jeval = benchmarks['jemalloc'][bname] | |
speedup = ((nojeval - jeval) / jeval) * 100 | |
print('|%s|%.3f|%.3f|%d%%' % (bname, nojeval, jeval, speedup)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment