Skip to content

Commit 900f28a

Browse files
aduh95nodejs-github-bot
authored andcommitted
doc: fixup perf_hooks
PR-URL: #35527 Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 91e0d9b commit 900f28a

File tree

1 file changed

+6
-71
lines changed

1 file changed

+6
-71
lines changed

doc/api/perf_hooks.md

+6-71
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ Performance Timeline. If `name` is provided, removes only the named mark.
5555

5656
### `performance.eventLoopUtilization([utilization1[, utilization2]])`
5757
<!-- YAML
58-
added: v14.10.0
58+
added:
59+
- v14.10.0
60+
- v12.19.0
5961
-->
6062

6163
* `utilization1` {Object} The result of a previous call to
@@ -222,62 +224,6 @@ obs.observe({ entryTypes: ['function'] });
222224
wrapped();
223225
```
224226

225-
### `performance.eventLoopUtilization([util1][,util2])`
226-
<!-- YAML
227-
added: v12.19.0
228-
-->
229-
230-
* `util1` {Object} The result of a previous call to `eventLoopUtilization()`
231-
* `util2` {Object} The result of a previous call to `eventLoopUtilization()`
232-
prior to `util1`
233-
* Returns {Object}
234-
* `idle` {number}
235-
* `active` {number}
236-
* `utilization` {number}
237-
238-
The `eventLoopUtilization()` method returns an object that contains the
239-
cumulative duration of time the event loop has been both idle and active as a
240-
high resolution milliseconds timer. The `utilization` value is the calculated
241-
Event Loop Utilization (ELU). If bootstrapping has not yet finished, the
242-
properties have the value of 0.
243-
244-
`util1` and `util2` are optional parameters.
245-
246-
If `util1` is passed then the delta between the current call's `active` and
247-
`idle` times are calculated and returned (similar to [`process.hrtime()`][]).
248-
Likewise the adjusted `utilization` value is calculated.
249-
250-
If `util1` and `util2` are both passed then the calculation adjustments are
251-
done between the two arguments. This is a convenience option because unlike
252-
[`process.hrtime()`][] additional work is done to calculate the ELU.
253-
254-
ELU is similar to CPU utilization except that it is calculated using high
255-
precision wall-clock time. It represents the percentage of time the event loop
256-
has spent outside the event loop's event provider (e.g. `epoll_wait`). No other
257-
CPU idle time is taken into consideration. The following is an example of how
258-
a mostly idle process will have a high ELU.
259-
260-
<!-- eslint-skip -->
261-
```js
262-
'use strict';
263-
const { eventLoopUtilization } = require('perf_hooks').performance;
264-
const { spawnSync } = require('child_process');
265-
266-
setImmediate(() => {
267-
const elu = eventLoopUtilization();
268-
spawnSync('sleep', ['5']);
269-
console.log(eventLoopUtilization(elu).utilization);
270-
});
271-
```
272-
273-
While the CPU is mostly idle while running this script the value of
274-
`utilization` is 1. This is because the call to [`child_process.spawnSync()`][]
275-
blocks the event loop from proceeding.
276-
277-
Passing in a user-defined object instead of the result of a previous call to
278-
`eventLoopUtilization()` will lead to undefined behavior. The return values
279-
are not guaranteed to reflect any correct state of the event loop.
280-
281227
## Class: `PerformanceEntry`
282228
<!-- YAML
283229
added: v8.5.0
@@ -405,7 +351,9 @@ initialized.
405351

406352
### `performanceNodeTiming.idleTime`
407353
<!-- YAML
408-
added: v14.10.0
354+
added:
355+
- v14.10.0
356+
- v12.19.0
409357
-->
410358

411359
* {number}
@@ -458,19 +406,6 @@ added: v8.5.0
458406
The high resolution millisecond timestamp at which the V8 platform was
459407
initialized.
460408

461-
### `performanceNodeTiming.idleTime`
462-
<!-- YAML
463-
added: v12.19.0
464-
-->
465-
466-
* {number}
467-
468-
The high resolution millisecond timestamp of the amount of time the event loop
469-
has been idle within the event loop's event provider (e.g. `epoll_wait`). This
470-
does not take CPU usage into consideration. If the event loop has not yet
471-
started (e.g., in the first tick of the main script), the property has the
472-
value of 0.
473-
474409
## Class: `perf_hooks.PerformanceObserver`
475410

476411
### `new PerformanceObserver(callback)`

0 commit comments

Comments
 (0)