Skip to content

Commit 26b7684

Browse files
committed
doc: update perf_hooks histogram docs
Update docs to match the event loop delay sampling changes.
1 parent 164ea8a commit 26b7684

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

doc/api/perf_hooks.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,10 @@ are not guaranteed to reflect any correct state of the event loop.
17061706

17071707
<!-- YAML
17081708
added: v11.10.0
1709+
changes:
1710+
- version: REPLACEME
1711+
pr-url: https://github.com/nodejs/node/pull/62935
1712+
description: Added the `samplePerIteration` option.
17091713
-->
17101714

17111715
* `options` {Object}
@@ -1714,18 +1718,20 @@ added: v11.10.0
17141718
* `resolution` {number} The sampling rate in milliseconds for interval-based
17151719
sampling. Must be greater than zero. This option is ignored when
17161720
`samplePerIteration` is `true`. **Default:** `10`.
1717-
* Returns: {IntervalHistogram}
1721+
* Returns: {IntervalHistogram|ELDHistogram}
17181722

17191723
_This property is an extension by Node.js. It is not available in Web browsers._
17201724

1721-
Creates an `IntervalHistogram` object that samples and reports the event loop
1722-
delay over time. The delays will be reported in nanoseconds.
1725+
Creates a histogram object that samples and reports the event loop delay over
1726+
time. The delays will be reported in nanoseconds.
17231727

17241728
By default, the histogram is updated by a timer using the configured
17251729
`resolution`. When `samplePerIteration` is `true`, samples are taken once per
17261730
event loop iteration using `uv_prepare_t` and `uv_check_t` hooks. In that mode,
17271731
the histogram does not keep the loop alive or force additional iterations when
17281732
the application is idle.
1733+
The two sampling modes produce significantly different results and should not
1734+
be compared directly.
17291735

17301736
```mjs
17311737
import { monitorEventLoopDelay } from 'node:perf_hooks';
@@ -2004,7 +2010,7 @@ The standard deviation of the recorded event loop delays.
20042010

20052011
## Class: `IntervalHistogram extends Histogram`
20062012

2007-
A `Histogram` that records event loop delay.
2013+
A `Histogram` that records event loop delay using interval-based sampling.
20082014

20092015
### `histogram.disable()`
20102016

@@ -2045,11 +2051,17 @@ const { monitorEventLoopDelay } = require('node:perf_hooks');
20452051
}
20462052
```
20472053

2048-
### Cloning an `IntervalHistogram`
2054+
### Cloning event loop delay histograms
2055+
2056+
{IntervalHistogram} and {ELDHistogram} instances can be cloned via
2057+
{MessagePort}. On the receiving end, the histogram is cloned as a plain
2058+
{Histogram} object that does not implement the `enable()` and `disable()`
2059+
methods.
2060+
2061+
## Class: `ELDHistogram extends Histogram`
20492062

2050-
{IntervalHistogram} instances can be cloned via {MessagePort}. On the receiving
2051-
end, the histogram is cloned as a plain {Histogram} object that does not
2052-
implement the `enable()` and `disable()` methods.
2063+
A `Histogram` that records event loop delay once per event loop iteration. It
2064+
provides the same API as {IntervalHistogram}.
20532065

20542066
## Class: `RecordableHistogram extends Histogram`
20552067

0 commit comments

Comments
 (0)