Index of every page on this site: llms.txt
All skills
jasnell avatar

/node-histogram-stats

@5f83e6c
Run it yourself

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+.

Use this Skill: https://skilld.dev/gh/jasnell/node-skills/node-histogram-stats

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

rulesonline-slo.md

≈715 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Online stats: EWMA, burn rate, coordinated omission, sliding windows

EWMA options on createHistogram

createHistogram({ halfLife, threshold }). The YAML has no changes: entry for these options. They ship with the EWMA getters (v26.8.0; v24.21.0 for most getters).

  • halfLife is in samples, not time. After halfLife recordings, a value has 50% influence. The default 0 disables EWMA.
  • threshold uses the same unit as the recorded values (for example 200 ms as 200_000_000 ns). It needs halfLife.
  • ewmaMean (YAML: v26.8.0 only), ewmaStddev, ewmaErrorRate (v26.8.0, v24.21.0). They are 0 when disabled or when no values are recorded.
  • burnRate(sloTarget) (v26.8.0, v24.21.0) is ewmaErrorRate / (1 - sloTarget). sloTarget must be in (0, 1), otherwise it throws ERR_OUT_OF_RANGE. A value above 1 means the error budget burns faster than allowed. Verified: without halfLife and threshold it returns 0 and does not throw.

Verified: with halfLife: 10, 100 records of 100 followed by 10 records of 300 give ewmaMean === 200 and ewmaErrorRate ≈ 0.5, with the threshold at 200.

EWMA state survives snapshot() and export()/importHistogram(). diff() results have no EWMA state.

recordCorrected(val, expectedInterval) (v26.8.0, v24.21.0)

This is HdrHistogram coordinated-omission correction. Verified behavior: each call records val, then val - i, val - 2i, … while the value is >= i. It does not depend on earlier records:

  • recordCorrected(1000, 100) records 10 values (1000, 900, …, 100).
  • recordCorrected(950, 100) then recordCorrected(1000, 100) records 19.
  • A value below expectedInterval is recorded once.

Use it when a load generator sends at a fixed rate and a stall delays measurement. expectedInterval is the intended send interval, in the same unit.

createSlidingWindowHistogram(options) (v26.10.0, v24.22.0)

  • chunks is 1-1024. Pass exactly one of chunkDuration (ms) and recordsPerChunk. Passing both or neither throws ERR_INVALID_ARG_VALUE. lowest, highest and figures work as in createHistogram.
  • Methods: record(val), snapshot() → Histogram, and reset(). There are no stats on the window itself, so always use snapshot(). The window cannot be constructed directly (ERR_ILLEGAL_CONSTRUCTOR) or sent over a MessagePort.
  • Rotation is lazy and uses no timer. A time window keeps a value for between (N-1)*D and N*D ms. A count window keeps between (N-1)*C+1 and N*C attempts, and attempts above highest count toward rotation (verified: they show up in snapshot().exceeds).
const win = createSlidingWindowHistogram({ chunks: 6, chunkDuration: 10_000 }); // ~last 60 s
win.record(latencyNs);
const s = win.snapshot();
report(s.percentile(99), s.ccdf(slo));

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts5d3 checks · Risk SAFE
  • Gen Agent Trust Hub5d

    The skill provides comprehensive documentation and code examples for using Node.js built-in performance histogram statistics (available in Node.js 24+). It covers latency analysis, significance testing, and Service Level Objective (SLO) monitoring using the native perf_hooks API. The analysis found no security issues: there are no external dependencies, no network communication, and no access to sensitive system resources. All examples use standard Node.js APIs as intended.

  • Socket5d

    No alerts

  • Snyk5d

    Risk: LOW · No issues

Signed by skilld at 5f83e6c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 days ago.

Activeupdated last week

README badge

README badge for jasnell/node-skills/node-histogram-stats