Skip to content

Instantly share code, notes, and snippets.

@cdiener cdiener/
Last active Mar 6, 2017

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},
return df
if __name__ == "__main__":
if len(argv) != 3:
print("Usage: before.json after.json")
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]
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.