Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+64 added−0 removed
other:+64 added−0 removed
Provenance
Commit
f1557d4
Tree
e8f176c
Author
David Peter <mail@david-peter.de>
Committer
David Peter <mail@david-peter.de>
Parent
bcd3705
2 files changed+64 added−0 removed
added:scripts/plot_progression.py+62 added
1+#!/usr/bin/env python2+3+"""This program shows `hyperfine` benchmark results in a sequential way4+in order to debug possible background interference, caching effects,5+thermal throttling and similar effects.6+"""7+8+import argparse9+import json10+import matplotlib.pyplot as plt11+import numpy as np12+13+14+def moving_average(times, num_runs):15+ times_padded = np.pad(16+ times, (num_runs // 2, num_runs - 1 - num_runs // 2), mode="edge"17+ )18+ kernel = np.ones(num_runs) / num_runs19+ return np.convolve(times_padded, kernel, mode="valid")20+21+22+parser = argparse.ArgumentParser(description=__doc__)23+parser.add_argument("file", help="JSON file with benchmark results")24+parser.add_argument("--title", help="Plot Title")25+parser.add_argument("-o", "--output", help="Save image to the given filename.")26+parser.add_argument(27+ "-w",28+ "--moving-average-width",29+ type=int,30+ metavar="num_runs",31+ help="Width of the moving-average window (default: N/5)",32+)33+34+args = parser.parse_args()35+36+with open(args.file) as f:37+ results = json.load(f)["results"]38+39+label = results[0]["command"]40+times = results[0]["times"]41+num = len(times)42+nums = range(num)43+44+plt.scatter(x=nums, y=times, marker=".", color="orange")45+plt.ylim([0, None])46+plt.xlim([-1, num])47+48+moving_average_width = (49+ num // 5 if args.moving_average_width is None else args.moving_average_width50+)51+52+moving_average = moving_average(times, moving_average_width)53+plt.plot(nums, moving_average, "-", color="blue")54+55+if args.title:56+ plt.title(args.title)57+plt.legend(labels=[label], loc="best", fontsize="medium")58+plt.ylabel("Time [s]")59+if args.output:60+ plt.savefig(args.output)61+else:62+ plt.show()
modified:CHANGELOG.md+2 added
9 unmodified lines
10 (with a runtime on the order of a few milliseconds). See #336, #429,11 and #487 (@cipriancraciun and @sharkdp)12- Added `--setup` (`s`) option that can be used to run `make all` or13 similar. It runs once per set of tests, like `--cleanup` (`c`).14+- Added new `plot_progression.py` script to debug background interference15+ effects.1617## Changes1819- Breaking change: the `-s` short option for `--style` is now used for