Node.js Histogram Gets Statistical Benchmark Tests
Node.js 24.21.0 landed on the LTS line on September 8, 2026, carrying a feature that first shipped in 26.8.0 on August 26: statistical hypothesis testing built into the node:perf_hooks histogram. The difference between those two releases is not technical but practical — reaching LTS is what puts a feature where most production systems actually live.
The problem: one number decides nothing
The scenario is familiar. You run the benchmark on main, run it on your branch, and get two numbers. The branch is 4% slower. Is that a real regression, or noise from CPU scheduling and a noisy neighbour on the same runner? The mean alone will not answer, and neither will p99 on its own, because every measurement is a sample from a distribution rather than a fact.
Statistics has answered this for decades — significance tests and effect sizes — but reaching for them meant dumping millions of samples to a file and piping them through an external Python or R script. That path works, and it is heavy enough that it quietly disappears from pull requests after the first week.
What changed
The Node.js histogram was already a compact HDR structure that records millions of values in fixed memory. This release built a full analysis layer on top of it, running inside the same process:
welchTest(other, { confidence })— Welch's t-test for means, returning an object withtStatistic,degreesOfFreedom,pValueandconfidenceInterval.mannWhitneyTest(other)— a non-parametric alternative returninguStatistic,zScoreandpValue, better suited to the skewed shape of latency data.ksTest(other)— the Kolmogorov-Smirnov statistic, where zero means identical distributions.cohensD(other)andcliffsD(other)— effect size, meaning whether the difference is worth anyone's attention.percentileCI(p, { confidence })andmeanCI({ confidence })— confidence intervals around a percentile or the mean instead of a bare number.skewnessandkurtosis— distribution shape, for spotting heavy tails.ewmaMean,ewmaStddev,ewmaErrorRateandburnRate(sloTarget)— continuous production monitoring, not just benchmarking.
A practical example
import { createHistogram } from 'node:perf_hooks';
function measure(fn, runs = 5000) {
const h = createHistogram();
for (let i = 0; i < runs; i++) {
const start = process.hrtime.bigint();
fn();
h.record(process.hrtime.bigint() - start);
}
return h;
}
const base = measure(renderBaseline);
const next = measure(renderCandidate);
const t = next.welchTest(base);
const effect = next.cliffsD(base);
const p99 = next.percentileCI(99);
console.log(`p99: ${p99.value}ns [${p99.lower}, ${p99.upper}]`);
if (t.pValue < 0.05 && Math.abs(effect) > 0.33) {
console.error(`regression: p=${t.pValue.toFixed(4)} cliffsD=${effect.toFixed(2)}`);
process.exitCode = 1;
}Two conditions together: the difference is statistically significant (pValue) and large enough to matter (cliffsD). That pairing is exactly what stops CI from shouting about a 0.3% shift no user will ever perceive.
For live monitoring, createHistogram accepts halfLife and threshold at creation time. ewmaErrorRate then becomes the smoothed probability of a recorded value exceeding that threshold, and burnRate(0.999) reports how fast the error budget is being consumed — a burn rate of 1 means the budget will be exhausted exactly at the end of the SLO window.
Real-world caveats
- A p-value is not a permission slip. With tens of thousands of samples, trivial differences become "statistically significant", which is why
welchTestshould never be read withoutcliffsDorcohensDbeside it. - The histogram is a deliberately lossy structure: the default
figuresprecision is three significant digits, and recorded values are rounded into buckets. The tests run on that compressed data, not on raw samples. welchTestassumes the two samples are independent. Interleaving both variants inside one process breaks that assumption.- These APIs exist in 24.21.0 and 26.8.0, not in 22.x. Pin your Node.js version in CI before depending on them.
- A shared runner is still a source of noise. Statistics measures noise; it does not remove it.
Takeaway
The vision here is larger than the feature: serious measurement moves from a side script into a runtime capability. When regression detection is two lines in CI rather than a whole pipeline, it changes from something teams intend to do into something that runs every time. If you already trace performance with Perfetto, this layer completes what that one started: Node.js 26.7.0 adds Perfetto tracing.
Primary sources: the Node.js 24.21.0 release notes and PR #65416.