Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve eventLoopUtilization documentation #35479

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions doc/api/perf_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ Performance Timeline. If `name` is provided, removes only the named mark.
added: v14.10.0
-->

* `utilization1` {Object} The result of a previous call to `eventLoopUtilization()`
* `utilization2` {Object} The result of a previous call to `eventLoopUtilization()`
prior to `util1`
* `utilization1` {Object} The result of a previous call to
`eventLoopUtilization()`.
* `utilization2` {Object} The result of a previous call to
`eventLoopUtilization()` prior to `utilization1`.
* Returns {Object}
* `idle` {number}
* `active` {number}
Expand All @@ -70,9 +71,9 @@ The `eventLoopUtilization()` method returns an object that contains the
cumulative duration of time the event loop has been both idle and active as a
high resolution milliseconds timer. The `utilization` value is the calculated
Event Loop Utilization (ELU). If bootstrapping has not yet finished, the
properties have the value of 0.
properties have the value of `0`.

`utilization1` and `utilization2` are optional parameters.
Both `utilization1` and `utilization2` are optional parameters.

If `utilization1` is passed, then the delta between the current call's `active`
and `idle` times, as well as the corresponding `utilization` value are
Expand Down Expand Up @@ -102,8 +103,8 @@ setImmediate(() => {
```

Although the CPU is mostly idle while running this script, the value of
`utilization` is 1. This is because the call to [`child_process.spawnSync()`][]
blocks the event loop from proceeding.
`utilization` is `1`. This is because the call to
[`child_process.spawnSync()`][] blocks the event loop from proceeding.

Passing in a user-defined object instead of the result of a previous call to
`eventLoopUtilization()` will lead to undefined behavior. The return values
Expand Down