Skip to content

Instantly share code, notes, and snippets.

@tonybaloney
Created April 2, 2018 12:18
Show Gist options
  • Save tonybaloney/4e8e45f9128e9eb6e4f36c73ba5e5574 to your computer and use it in GitHub Desktop.
Save tonybaloney/4e8e45f9128e9eb6e4f36c73ba5e5574 to your computer and use it in GitHub Desktop.
import argparse
from pathlib import Path
from perf._bench import BenchmarkSuite
import seaborn as sns
import pandas as pd
sns.set(style="whitegrid")
parser = argparse.ArgumentParser(description='Convert a list of benchmarks into a CSV')
parser.add_argument('files', metavar='N', type=str, nargs='+',
help='files to compare')
args = parser.parse_args()
benchmark_names = []
records = []
first = True
for f in args.files:
benchmark_suite = BenchmarkSuite.load(f)
if first:
# Initialise the dictionary keys to the benchmark names
benchmark_names = benchmark_suite.get_benchmark_names()
first = False
bench_name = Path(benchmark_suite.filename).name
for name in benchmark_names:
try:
benchmark = benchmark_suite.get_benchmark(name)
if benchmark is not None:
records.append({
'test': name,
'runtime': bench_name.replace('.json', ''),
'stdev': benchmark.stdev(),
'mean': benchmark.mean(),
'median': benchmark.median()
})
except KeyError:
# Bonus benchmark! ignore.
pass
df = pd.DataFrame(records)
for test in benchmark_names:
# Draw a pointplot to show pulse as a function of three categorical factors
g = sns.factorplot(
x="runtime",
y="mean",
data=df[df['test'] == test],
#capsize=.2,
palette="YlGnBu_d",
size=12,
aspect=1,
kind="bar")
g.despine(left=True)
g.savefig("png/{}-result.png".format(test))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment