Files
node/doc/api
James M Snell a3bb551ea7 perf_hooks: add histogram.diff()
Getting the values recorded during an interval requires calling
`reset()`, which removes them for every other user of the histogram,
or copying and subtracting histograms, which silently produces a wrong
result when the source was reset in between.

Add `histogram.diff(other)`, which returns a new read-only `Histogram`
containing the values recorded after `other`, an earlier snapshot of
the histogram, was taken. Neither histogram is changed. Unlike
`subtract()`, it verifies that both histograms have the same layout,
and it throws instead of clamping when `other` contains values that
the histogram does not.

Add `histogram.resetCount`, the number of calls to `reset()` and
`subtract()`, which `snapshot()` copies. `diff()` throws when the
counts differ, so a reset between two snapshots is detected even when
every bucket has since grown past its previous count.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: OpenCode
PR-URL: https://github.com/nodejs/node/pull/66099
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-25 03:31:53 +00:00
..
2026-09-16 20:13:19 +02:00
2026-09-19 05:21:30 +00:00
2026-09-03 11:40:52 +02:00
2026-09-22 10:59:57 +02:00
2026-09-22 10:59:57 +02:00
2026-09-22 10:59:57 +02:00
2026-09-03 15:37:21 +00:00
2025-12-16 20:31:28 +00:00
2026-09-11 13:15:27 -04:00
2026-09-25 03:31:53 +00:00
2026-08-03 11:44:23 +00:00
2026-09-22 10:59:57 +02:00
2026-09-09 18:04:31 +02:00
2026-09-16 20:13:19 +02:00
2026-09-11 14:57:08 +00:00