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

Add plot_parametrized.py scriptsharkdpbefore adoption0d22a96

lines 1–11why, one step back
1#!/usr/bin/python
23"""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="+")

Auto-format Python scriptssharkdpbefore adoption8fff864

lines 12–17why, one step back
12parser.add_argument(
13 "--parameter-name",14 metavar="name",15 type=str,16 help="Name of the parameter / x-axis label",17)

Add plot_parametrized.py scriptsharkdpbefore adoption0d22a96

lines 18–27why, one step back
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]27

Auto-format Python scriptssharkdpbefore adoption8fff864

line 28why, one step back
28 plt.errorbar(x=parameter_values, y=times_mean, yerr=times_stddev, capsize=2)

Add plot_parametrized.py scriptsharkdpbefore adoption0d22a96

lines 29–33why, one step back
29
30plt.xlabel(args.parameter_name)31plt.ylabel("Time [s]")32plt.ylim(0, None)33plt.show()