Skip to content

perf_hooks: add statistical hypothesis testing to histogram - #65416

Open
jasnell wants to merge 2 commits into
nodejs:mainfrom
jasnell:jasnell/more-histogram-fun
Open

perf_hooks: add statistical hypothesis testing to histogram#65416
jasnell wants to merge 2 commits into
nodejs:mainfrom
jasnell:jasnell/more-histogram-fun

Conversation

@jasnell

@jasnell jasnell commented Aug 20, 2026

Copy link
Copy Markdown
Member

Continue expanding the capabilities of the Histogram API... and use it to enable a dependency-free benchmark/compare.js option... i.e. no longer requiring R-script to show benchmark analysis... just run benchmark/compare.js with the --analyze option.

The added algorithms cover analysis calculations that would be fairly common in perf analysis (latency, burn rates, detecting regressions, etc). Prior to this, really the only way to get these were to use aging outside dependencies (5+ years old) or R-script.

Just scratching an old itch I've been wanting since I added Histogram back in v11. I've been doing a bunch of benchmarking lately with the QUIC and DTLS impls and just got tired of having to use outside deps for this stuff.

/cc @mcollina

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/tsc

@jasnell
jasnell requested review from Qard and mcollina August 20, 2026 06:25
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Aug 20, 2026
Welch's t-test, Mann-Whitney U test, Cohen's d, and Cliff's delta,
and and handful of others

These methods enable in-process benchmark comparison and regression
detection without external dependencies.

No new dependencies.

Tests and docs created by the AI agent.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
Add an --analyze flag that performs statistical analysis directly
after benchmarks complete, eliminating the need for R and compare.R.

When --analyze is specified, compare.js collects the rate data during
the run and prints a statistical summary table instead of CSV output.
The table matches the format of compare.R: improvement percentage,
significance stars (* p<0.05, ** p<0.01, *** p<0.001), and confidence
intervals at three risk levels.

Also adds a --max-regression N option that causes the compare.js to
exit with 1 (error) when the `--new` is N% slower. Useful for CI
use to detect regressions.

Uses the histogram API's welchTest() and cohensD() methods introduced
in the previous commit. Benchmark rates are scaled to integers for
HdrHistogram recording; the --scale option (default 1000) controls
the multiplier for precision.

Usage:
  node benchmark/compare.js --old ./node-old --new ./node-new \
    --analyze url

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
@jasnell
jasnell force-pushed the jasnell/more-histogram-fun branch from f866877 to bc4d71e Compare August 20, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants