bencher.sparkline
Inline-SVG sparklines for benchmark trend series.
A sparkline compresses a metric’s over-time series_for_var()
(per-event mean with a ±std noise band) into a tiny inline SVG, so both the trend
and the run-to-run spread are visible at a glance without opening a full report.
The output is pure numeric geometry — no caller strings are interpolated — so it
is safe to embed unescaped.
Functions
|
Return an inline SVG sparkline: ±std band, mean line, a node per run. |
Module Contents
- bencher.sparkline.sparkline_svg(means: list[float | None], stds: list[float | None], *, width: int = 120, height: int = 28, pad: int = 3) str
Return an inline SVG sparkline: ±std band, mean line, a node per run.
Pure-numeric input (no caller strings interpolated), so the output is safe to render unescaped. Auto-scales to the band extent; degenerates gracefully to a single node when only one finite point exists, and to an empty
<svg>when none do.The SVG carries a viewBox and
preserveAspectRatio="none"so CSS can stretch it to whatever width its container ends up at.vector-effectkeeps the line/band stroke crisp under that non-uniform scaling.A small node marks every event on the line so the eye can see where the individual runs sit; nodes are drawn identically (the latest is simply the rightmost) and the sparkline itself stays uncolored — the caller (e.g. a cell background) owns any verdict color.
With more than one point, a narrow right-margin column collapses every run’s mean onto the (shared) value axis as identical alpha-blended dots, so value regions where runs cluster read darker — surfacing the run-to-run spread, and any bimodality, that the mean line alone hides.
meansis the trend and drives the x-axis;stdsis the noise band and is paired positionally. The two are zipped withitertools.zip_longest()so a length mismatch degrades gracefully rather than silently dropping trailing points: a missing std collapses that point’s band to zero, and a surplus std (no matching mean) is ignored.