Skip to content
Myr

Add plot_parametrized.py script

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent aaf28f8 · Browse files · 1 file+32 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+32 added−0 removed

  • other:+32 added−0 removed

1 file+32 added−0 removed

added:scripts/plot_parametrized.py+32 added
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()