---
name: node-histogram-stats
description: "Statistics for latency and timing data with the built-in perf_hooks Histogram: significance tests, effect sizes, confidence intervals, percentiles, EWMA and SLO burn rate. Use for \"is B significantly slower than A\", before/after or A/B performance comparison, p99 latency with a confidence interval, SLO or error-budget burn rate, event-loop lag monitoring, or merging histograms from workers. Use it instead of simple-statistics or hdr-histogram-js. Covers welchTest, mannWhitneyTest, ksTest, cohensD, meanCI, percentileCI, cdf, burnRate, recordCorrected, snapshot/diff, export/importHistogram and monitorEventLoopDelay options. Node.js 24.12+; most need 24.21+ or 26.8+."
title: node-histogram-stats
canonical_url: https://skilld.dev/gh/jasnell/node-skills/node-histogram-stats
last_updated: 2026-11-19T20:15:43.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [examples/compare.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/examples/compare.mjs), [examples/distribution.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/examples/distribution.mjs), [examples/eld-options.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/examples/eld-options.mjs), [examples/event-loop.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/examples/event-loop.mjs), [examples/lifecycle.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/examples/lifecycle.mjs), [examples/slo.mjs](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/examples/slo.mjs), [meta.json](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/meta.json), [rules/distribution.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/distribution.md), [rules/event-loop.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/event-loop.md), [rules/inference.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/inference.md), [rules/lifecycle.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/lifecycle.md), [rules/online-slo.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/online-slo.md).
>
> If the user asked to install this Skill, run `npx skilld install jasnell/node-skills/node-histogram-stats`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/node-histogram-stats`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jasnell/node-skills/node-histogram-stats) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/node-histogram-stats`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/node-histogram-stats --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/node-histogram-stats --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# perf_hooks Histogram statistics

| Feature | Versions | Stability | Flag |
| --- | --- | --- | --- |
| `cdf` `ccdf` `countAt` `percentilesAt` `skewness` `kurtosis` `linearBuckets` `logBuckets` `percentileCI` `welchTest` `mannWhitneyTest` `ksTest` `cohensD` `cliffsD` `ewmaStddev` `ewmaErrorRate` `burnRate` `recordCorrected` `subtract` | v26.8.0, v24.21.0 | 2 | none |
| `ewmaMean` | v26.8.0 (YAML lists no v24) | 2 | none |
| `meanCI`, `importHistogram` | v26.9.0, v24.22.0 | 2 | none |
| `export()` (format v2 since v26.11.0) | v26.9.0 | 2 | none |
| `qrde`, `createSlidingWindowHistogram` | v26.10.0, v24.22.0 | 2 | none |
| `snapshot`, `diff`, `resetCount`, `record(0)`, ELD `lowest`/`highest`/`figures` | v26.11.0 (not on v24) | 2 | none |
| ELD `samplePerIteration` | v26.5.0, v24.19.0 | 2 | none |
| `perf_hooks.eventLoopUtilization`, `perf_hooks.timerify` | v25.2.0, v24.12.0 | 2 | none |

Values are unitless integers: you pick the unit. `monitorEventLoopDelay`,
`timerify` and `recordDelta` record **nanoseconds**; ELU is **ms**.

## Is B significantly slower than A?

```js
const w = a.welchTest(b);            // CI is on a.mean - b.mean
const slower = w.pValue < 0.05 && w.confidenceInterval.upper < 0;
const { pValue } = a.mannWhitneyTest(b); // skewed latency: rank test
a.cohensD(b); a.cliffsD(b); a.ksTest(b); // effect size / distance
```

## p99 with a CI

```js
const { value, lower, upper } = h.percentileCI(99, { confidence: 0.95 });
const m = h.meanCI();                // { mean, lower, upper }
```

## SLO burn rate

```js
const lat = createHistogram({ halfLife: 100, threshold: 200_000_000 }); // 200 ms in ns
lat.record(durationNs);
if (lat.burnRate(0.999) > 1) alert(); // ewmaErrorRate / (1 - 0.999)
```

## Interval deltas and merging workers

```js
const now = eld.snapshot();
const d = now.resetCount === prev.resetCount ? now.diff(prev) : now;
total.add(importHistogram(bytesFromWorker)); // worker sends h.export()
```

## Pitfalls

- `record()` needs integers ≥ 0 (≥ 1 before v26.11.0). `performance.now()` floats throw `ERR_OUT_OF_RANGE`.
- Interval-mode ELD samples **include** `resolution` (min ≈ 10e6 ns at the default 10 ms). Subtract it, or use `samplePerIteration: true`. Don't compare the two modes.
- Before v26.11.0, ELD `lowest`/`highest`/`figures` are **silently ignored**.
- Sign convention: `a.x(b)` is "a minus b". Negative t, d or delta means a is lower.
- With fewer than 2 samples, tests return `pValue: 1` and CIs return `NaN` or the point value. They do not throw.
- `burnRate()` without `halfLife` + `threshold` returns `0` and does not throw.
- `snapshot()`, `diff()` and sliding-window snapshots are read-only `Histogram`s. `add()` rejects them, so `importHistogram(x.export())` first.
- `recordCorrected(v, i)` backfills `v-i, v-2i, …` down to `i` on every call.

## Don't

- Don't hand-roll t-tests, percentile sorting or EWMA, and don't install `hdr-histogram-js`, `simple-statistics` or `jstat` for these.
- On v26.11+, don't copy with `createHistogram().add(total)` + `subtract()`. Use `snapshot()` + `diff()`.
- Don't call `reset()` per interval when other readers share the histogram. Diff snapshots instead.

## Reference

- [rules/inference.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/inference.md) — read for exact test return shapes, choosing a test, and edge cases.
- [rules/distribution.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/distribution.md) — read for cdf, buckets (key semantics), and qrde options.
- [rules/online-slo.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/online-slo.md) — read for EWMA, burnRate, recordCorrected, and sliding-window options.
- [rules/lifecycle.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/lifecycle.md) — read for snapshot/diff errors, export format, workers, and bigint getters.
- [rules/event-loop.md](https://skilld.dev/api/skills-raw/jasnell/node-skills/node-histogram-stats/rules/event-loop.md) — read for monitorEventLoopDelay options, units, ELU, and timerify.
