plot_parametrized.py
This file
Path
scripts/plot_parametrized.py
32 lines · 941 bytes · Python
Last changed by
Add plot_parametrized.py scriptsharkdpbefore adoption0d22a96
History of this fileTake it
1#!/usr/bin/python23"""This program shows parametrized `hyperfine` benchmark results as an4errorbar plot."""56import argparse7import json8import matplotlib.pyplot as plt910parser = argparse.ArgumentParser(description=__doc__)11parser.add_argument("file", help="JSON file with benchmark results", nargs="+")12parser.add_argument("--parameter-name", metavar="name", type=str,13 help="Name of the parameter / x-axis label")14args = parser.parse_args()1516for filename in args.file:17 with open(filename) as f:18 results = json.load(f)["results"]1920 parameter_values = [float(b["parameter"]) for b in results]21 times_mean = [b["mean"] for b in results]22 times_stddev = [b["stddev"] for b in results]2324 plt.errorbar(x=parameter_values,25 y=times_mean,26 yerr=times_stddev,27 capsize=2)2829plt.xlabel(args.parameter_name)30plt.ylabel("Time [s]")31plt.ylim(0, None)32plt.show()