Skip to content
Myr

plot_benchmark_results.py

This file

Path

scripts/plot_benchmark_results.py

28 lines · 820 bytes · Python

Last changed by

Use doc-comment for advanced_statistics.py scriptsharkdpbefore adoption02962d1

History of this file

Take it

Add script to plot benchmark resultssharkdpbefore adoption0ba8a20

lines 1–2why, one step back
1#!/usr/bin/python
2

Use doc-comment for advanced_statistics.py scriptsharkdpbefore adoption02962d1

lines 3–10why, one step back
3"""This program shows `hyperfine` benchmark results as a box and whisker plot.
45Quoting from the matplotlib documentation:6 The box extends from the lower to upper quartile values of the data, with7 a line at the median. The whiskers extend from the box to show the range8 of the data. Flier points are those past the end of the whiskers.9"""10

Add script to plot benchmark resultssharkdpbefore adoption0ba8a20

lines 11–14why, one step back
11import argparse
12import json13import matplotlib.pyplot as plt14

Use doc-comment for advanced_statistics.py scriptsharkdpbefore adoption02962d1

line 15why, one step back
15parser = argparse.ArgumentParser(description=__doc__)

Add script to plot benchmark resultssharkdpbefore adoption0ba8a20

lines 16–28why, one step back
16parser.add_argument("file", help="JSON file with benchmark results")
17args = parser.parse_args()1819with open(args.file) as f:20 results = json.load(f)["results"]2122commands = [b["command"] for b in results]23times = [b["times"] for b in results]2425plt.boxplot(times, labels=commands)26plt.ylabel("Time [s]")27plt.ylim(0, None)28plt.show()