Skip to content
Myr

plot_parametrized.py

This file

Path

scripts/plot_parametrized.py

33 lines · 889 bytes · Python

Last changed by

Auto-format Python scriptssharkdpbefore adoption8fff864

History of this file

Take 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(13    "--parameter-name",14    metavar="name",15    type=str,16    help="Name of the parameter / x-axis label",17)18args = parser.parse_args()1920for filename in args.file:21    with open(filename) as f:22        results = json.load(f)["results"]2324    parameter_values = [float(b["parameter"]) for b in results]25    times_mean = [b["mean"] for b in results]26    times_stddev = [b["stddev"] for b in results]2728    plt.errorbar(x=parameter_values, y=times_mean, yerr=times_stddev, capsize=2)2930plt.xlabel(args.parameter_name)31plt.ylabel("Time [s]")32plt.ylim(0, None)33plt.show()