Methodology 0.5 (draft) · other versions: 0.2 · what this means
Compare
Any two versions or configurations on the same machine
machinesT = transpose(machines)
runsT = transpose(runs)
estT = transpose(est)
profT = transpose(prof)
suiteOf = new Map(transpose(benchmarks).map(d => [d.id, d.suite]))
choices = runsT.filter(d => d.machine === machine)
.sort((p, q) => (p.kind === q.kind ? p.date.localeCompare(q.date) || p.config.localeCompare(q.config)
: p.kind === "release" ? -1 : 1))
dark = Generators.observe(notify => {
const f = () => notify(document.body.classList.contains("quarto-dark"));
f();
const o = new MutationObserver(f);
o.observe(document.body, {attributes: true, attributeFilter: ["class"]});
return () => o.disconnect();
})
css = { dark; const s = getComputedStyle(document.body); return n => s.getPropertyValue(n).trim(); }
rows = {
const a = new Map(estT.filter(e => e.run === A.run).map(e => [e.benchmark, e]));
const out = [];
for (const e of estT) {
if (e.run !== B.run || !a.has(e.benchmark)) continue;
const x = a.get(e.benchmark);
const d = x.log_mean - e.log_mean, se = Math.hypot(x.log_se, e.log_se);
const sp = Math.exp(d), q = tq[Math.min(Math.max(x.n + e.n - 2, 1), tq.length) - 1];
out.push({benchmark: e.benchmark, suite: suiteOf.get(e.benchmark), speedup: sp, se,
lo: Math.exp(d - q * se), hi: Math.exp(d + q * se), ta: x.est_ms, tb: e.est_ms,
sig: Math.abs(d) > q * se && Math.abs(sp - 1) > 0.02});
}
return out.sort((p, q) => q.speedup - p.speedup);
}
geo = {
const n = rows.length;
const m = rows.reduce((s, r) => s + Math.log(r.speedup), 0) / n;
const se = Math.sqrt(rows.reduce((s, r) => s + r.se ** 2, 0)) / n;
return {n, speedup: Math.exp(m), lo: Math.exp(m - 1.96 * se), hi: Math.exp(m + 1.96 * se),
faster: rows.filter(r => r.sig && r.speedup > 1).length,
slower: rows.filter(r => r.sig && r.speedup < 1).length};
}
fmtX = (x, d = 2) => x.toFixed(d) + "×"
tone = r => r.sig ? (r.speedup > 1 ? css("--rs-fast") : css("--rs-slow")) : css("--rs-neutral")
groupDelta = {
const pa = new Map(profT.filter(p => p.run === A.run).map(p => [p.benchmark, p]));
const pb = new Map(profT.filter(p => p.run === B.run).map(p => [p.benchmark, p]));
const common = rows.filter(r => pa.has(r.benchmark) && pb.has(r.benchmark));
if (!common.length) return null;
const TA = common.reduce((s, r) => s + r.ta, 0);
return groups.map(g => {
const a = common.reduce((s, r) => s + r.ta * pa.get(r.benchmark)[g], 0) / TA;
const b = common.reduce((s, r) => s + r.tb * pb.get(r.benchmark)[g], 0) / TA;
return {group: g, a, b, delta: b - a};
});
}html`<div class="rs-tiles">
<div class="rs-tile"><div class="rs-tile-label">${B.label} vs ${A.label}</div>
<div class="rs-tile-value">${fmtX(geo.speedup)}</div>
<div class="rs-tile-sub">geomean · 95% CI ${fmtX(geo.lo, 3)}–${fmtX(geo.hi, 3)}</div></div>
<div class="rs-tile"><div class="rs-tile-label">Benchmarks compared</div>
<div class="rs-tile-value">${geo.n}</div>
<div class="rs-tile-sub">ran on both versions</div></div>
<div class="rs-tile"><div class="rs-tile-label">Faster in B</div>
<div class="rs-tile-value">${geo.faster}</div>
<div class="rs-tile-sub"><span class="rs-status rs-status-good">▲ faster</span> by more than 2%, outside the interval</div></div>
<div class="rs-tile"><div class="rs-tile-label">Slower in B</div>
<div class="rs-tile-value">${geo.slower}</div>
<div class="rs-tile-sub"><span class="rs-status rs-status-critical">▼ slower</span> by more than 2%, outside the interval</div></div>
</div>`html`<div class="rs-card"><div class="rs-card-title">Where the time went</div>
<div class="rs-card-sub">Time per category group in B minus A, as a share of A's total time over the compared benchmarks. Left of zero is time saved.</div>
${groupDelta === null
? html`<div class="rs-empty">No profiles for this pair (profiles are recorded for the default configuration only).</div>`
: Plot.plot({
width, height: 240, marginLeft: 110, marginRight: 70, marginBottom: 46,
style: {background: "transparent", color: css("--rs-ink2"), fontFamily: "system-ui, sans-serif", fontSize: "13px"},
x: {label: "Change in time, as % of A's total →", labelAnchor: "center", labelOffset: 40, ticks: 6, tickFormat: d => (d * 100).toFixed(1) + "%", grid: true},
y: {label: null, domain: groups},
marks: [
Plot.gridX({stroke: css("--rs-grid"), strokeOpacity: 1}),
Plot.barX(groupDelta, {y: "group", x: "delta", inset: 2, rx: 4,
fill: d => d.delta < 0 ? css("--rs-fast") : css("--rs-slow")}),
Plot.ruleX([0], {stroke: css("--rs-axis")}),
Plot.text(groupDelta, {y: "group", x: d => Math.max(0, d.delta), dx: 6, textAnchor: "start", fill: css("--rs-ink"),
text: d => (d.delta >= 0 ? "+" : "−") + Math.abs(d.delta * 100).toFixed(1) + "%"}),
Plot.tip(groupDelta, Plot.pointerY({y: "group", x: "delta",
title: d => `${d.group}\nA: ${(d.a * 100).toFixed(1)}% of A's time\nB: ${(d.b * 100).toFixed(1)}% of A's time`}))
]})}
</div>`html`<div class="rs-card"><div class="rs-card-title">Per benchmark</div>
<div class="rs-card-sub">Dot = speedup of B over A, line = 95% interval. Blue: significantly faster; red: significantly slower; grey: within noise or under 2%.</div>
${Plot.plot({
width, height: rows.length * 13 + 60, marginLeft: 320, marginRight: 30,
style: {background: "transparent", color: css("--rs-ink2"), fontFamily: "system-ui, sans-serif", fontSize: "11px"},
x: {type: "log", label: "Speedup of B over A (×) →", grid: true, tickFormat: d => d + "×"},
y: {label: null, domain: rows.map(d => d.benchmark)},
marks: [
Plot.gridX({stroke: css("--rs-grid"), strokeOpacity: 1}),
Plot.ruleX([1], {stroke: css("--rs-axis"), strokeWidth: 1.5}),
Plot.ruleY(rows, {y: "benchmark", x1: "lo", x2: "hi", stroke: tone, strokeWidth: 2}),
Plot.dot(rows, {y: "benchmark", x: "speedup", r: 4, fill: tone, stroke: css("--rs-surface"), strokeWidth: 1.5}),
Plot.tip(rows, Plot.pointerY({y: "benchmark", x: "speedup",
title: d => `${d.benchmark}\n${fmtX(d.speedup, 3)} (95% CI ${fmtX(d.lo, 3)}–${fmtX(d.hi, 3)})\nA ${d.ta.toFixed(0)} ms → B ${d.tb.toFixed(0)} ms`}))
]})}
</div>`Table view
Inputs.table(rows, {
columns: ["suite", "benchmark", "ta", "tb", "speedup", "lo", "hi"],
header: {suite: "Suite", benchmark: "Benchmark", ta: "A (ms)", tb: "B (ms)", speedup: "Speedup", lo: "CI low", hi: "CI high"},
format: {ta: d => d.toFixed(1), tb: d => d.toFixed(1), speedup: d => fmtX(d, 3), lo: d => fmtX(d, 3), hi: d => fmtX(d, 3)},
rows: 20, layout: "auto"
})- A speedup above 1× means B is faster than A. Only benchmarks that ran in both are compared.
- Intervals are 95% intervals over the R processes of each run.