Skip to content
Myr

plot_whisker.py

This file

Path

scripts/plot_whisker.py

51 lines · 1.5 KiB · Python

Last changed by

Change parameter name in plotting scriptsBenjamin Rosemannbefore adoption49fcc4b

History of this file

Take it

The walk stopped after 200 commits: lines older than 1a4b5df point at it.

scripts: modify shebang to use "/usr/bin/env python"muxatorbefore adoption5a80a23

line 1why, one step back
1#!/usr/bin/env python

Bump libc from 0.2.64 to 0.2.65dependabot-preview[bot]before adoption1a4b5df

lines 2–16why, one step back
2
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"""1011import argparse12import json13import matplotlib.pyplot as plt1415parser = argparse.ArgumentParser(description=__doc__)16parser.add_argument("file", help="JSON file with benchmark results")

Update plot_whisker.pyEugene Obrezkovbefore adoptione83e1f7

line 17why, one step back
17parser.add_argument("--title", help="Plot Title")

Auto-format Python scriptssharkdpbefore adoption8fff864

lines 18–20why, one step back
18parser.add_argument(
19 "--labels", help="Comma-separated list of entries for the plot legend"20)

Change parameter name in plotting scriptsBenjamin Rosemannbefore adoption49fcc4b

lines 21–24why, one step back
21parser.add_argument(
22 "-o", "--output", help="Save image to the given filename."23)24

Bump libc from 0.2.64 to 0.2.65dependabot-preview[bot]before adoption1a4b5df

lines 25–29why, one step back
25args = parser.parse_args()
2627with open(args.file) as f:28 results = json.load(f)["results"]29

Add --labels option for plot_whisker.pysharkdpbefore adoptiona870d4d

lines 30–33why, one step back
30if args.labels:
31 labels = args.labels.split(",")32else:33 labels = [b["command"] for b in results]

Bump libc from 0.2.64 to 0.2.65dependabot-preview[bot]before adoption1a4b5df

lines 34–35why, one step back
34times = [b["times"] for b in results]
35

Update plot_whisker.pyEugene Obrezkovbefore adoptione83e1f7

lines 36–42why, one step back
36boxplot = plt.boxplot(times, vert=True, patch_artist=True)
37cmap = plt.cm.get_cmap("rainbow")38colors = [cmap(val / len(times)) for val in range(len(times))]3940for patch, color in zip(boxplot["boxes"], colors):41 patch.set_facecolor(color)42

Only show title if it is setDavid Peterbefore adoption907d38a

lines 43–44why, one step back
43if args.title:
44 plt.title(args.title)

Add --labels option for plot_whisker.pysharkdpbefore adoptiona870d4d

line 45why, one step back
45plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")

Bump libc from 0.2.64 to 0.2.65dependabot-preview[bot]before adoption1a4b5df

line 46why, one step back
46plt.ylabel("Time [s]")

Update plot_whisker.pyEugene Obrezkovbefore adoption9253e9f

line 47why, one step back
47plt.ylim(0, None)

Change parameter name in plotting scriptsBenjamin Rosemannbefore adoption49fcc4b

lines 48–49why, one step back
48if args.output:
49 plt.savefig(args.output)

Add parameters to plotting scriptsBenjamin Rosemannbefore adoptionb04a9ec

lines 50–51why, one step back
50else:
51 plt.show()