Skip to content

Instantly share code, notes, and snippets.

@cdiener cdiener/compare.py
Last active Mar 6, 2017

Embed
What would you like to do?
Compare pytest benchmarks
import json
import pandas as pd
from sys import argv, exit
def benchmark_to_df(json_file):
with open(json_file) as jf:
content = json.load(jf)
df = pd.DataFrame(columns=("test", "time [ms]"))
for b in content["benchmarks"]:
df = df.append({"test": b["name"],
"time [ms]": b["stats"]["mean"]*1000.0},
ignore_index=True)
return df
if __name__ == "__main__":
if len(argv) != 3:
print("Usage: compare.py before.json after.json")
exit(1)
before = benchmark_to_df(argv[1])
after = benchmark_to_df(argv[2])
both = pd.merge(before, after, how="inner", on="test",
suffixes=(" before", " after"))
both["fraction"] = both.iloc[:, 1] / both.iloc[:, 2]
print(both.sort("fraction"))
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.