Skip to content

Commit ca0302e

Browse files
Trottrichardlau
authored andcommitted
doc: arrange perf_hooks entries alphabetically
Entries in perf_hooks.md are almost-but-not-quite in alphabetical order. Our docs (usually) list things in alphabetical order, so move a few entries to make it so in perf_hooks.md. PR-URL: #34973 Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Harshitha K P <[email protected]>
1 parent 46766a1 commit ca0302e

File tree

1 file changed

+102
-100
lines changed

1 file changed

+102
-100
lines changed

doc/api/perf_hooks.md

+102-100
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,62 @@ added: v8.5.0
5353
If `name` is not provided, removes all `PerformanceMark` objects from the
5454
Performance Timeline. If `name` is provided, removes only the named mark.
5555

56+
### `performance.eventLoopUtilization([util1][,util2])`
57+
<!-- YAML
58+
added: REPLACEME
59+
-->
60+
61+
* `util1` {Object} The result of a previous call to `eventLoopUtilization()`
62+
* `util2` {Object} The result of a previous call to `eventLoopUtilization()`
63+
prior to `util1`
64+
* Returns {Object}
65+
* `idle` {number}
66+
* `active` {number}
67+
* `utilization` {number}
68+
69+
The `eventLoopUtilization()` method returns an object that contains the
70+
cumulative duration of time the event loop has been both idle and active as a
71+
high resolution milliseconds timer. The `utilization` value is the calculated
72+
Event Loop Utilization (ELU). If bootstrapping has not yet finished, the
73+
properties have the value of 0.
74+
75+
`util1` and `util2` are optional parameters.
76+
77+
If `util1` is passed then the delta between the current call's `active` and
78+
`idle` times are calculated and returned (similar to [`process.hrtime()`][]).
79+
Likewise the adjusted `utilization` value is calculated.
80+
81+
If `util1` and `util2` are both passed then the calculation adjustments are
82+
done between the two arguments. This is a convenience option because unlike
83+
[`process.hrtime()`][] additional work is done to calculate the ELU.
84+
85+
ELU is similar to CPU utilization except that it is calculated using high
86+
precision wall-clock time. It represents the percentage of time the event loop
87+
has spent outside the event loop's event provider (e.g. `epoll_wait`). No other
88+
CPU idle time is taken into consideration. The following is an example of how
89+
a mostly idle process will have a high ELU.
90+
91+
<!-- eslint-skip -->
92+
```js
93+
'use strict';
94+
const { eventLoopUtilization } = require('perf_hooks').performance;
95+
const { spawnSync } = require('child_process');
96+
97+
setImmediate(() => {
98+
const elu = eventLoopUtilization();
99+
spawnSync('sleep', ['5']);
100+
console.log(eventLoopUtilization(elu).utilization);
101+
});
102+
```
103+
104+
While the CPU is mostly idle while running this script the value of
105+
`utilization` is 1. This is because the call to [`child_process.spawnSync()`][]
106+
blocks the event loop from proceeding.
107+
108+
Passing in a user-defined object instead of the result of a previous call to
109+
`eventLoopUtilization()` will lead to undefined behavior. The return values
110+
are not guaranteed to reflect any correct state of the event loop.
111+
56112
### `performance.mark([name])`
57113
<!-- YAML
58114
added: v8.5.0
@@ -163,62 +219,6 @@ obs.observe({ entryTypes: ['function'] });
163219
wrapped();
164220
```
165221

166-
### `performance.eventLoopUtilization([util1][,util2])`
167-
<!-- YAML
168-
added: REPLACEME
169-
-->
170-
171-
* `util1` {Object} The result of a previous call to `eventLoopUtilization()`
172-
* `util2` {Object} The result of a previous call to `eventLoopUtilization()`
173-
prior to `util1`
174-
* Returns {Object}
175-
* `idle` {number}
176-
* `active` {number}
177-
* `utilization` {number}
178-
179-
The `eventLoopUtilization()` method returns an object that contains the
180-
cumulative duration of time the event loop has been both idle and active as a
181-
high resolution milliseconds timer. The `utilization` value is the calculated
182-
Event Loop Utilization (ELU). If bootstrapping has not yet finished, the
183-
properties have the value of 0.
184-
185-
`util1` and `util2` are optional parameters.
186-
187-
If `util1` is passed then the delta between the current call's `active` and
188-
`idle` times are calculated and returned (similar to [`process.hrtime()`][]).
189-
Likewise the adjusted `utilization` value is calculated.
190-
191-
If `util1` and `util2` are both passed then the calculation adjustments are
192-
done between the two arguments. This is a convenience option because unlike
193-
[`process.hrtime()`][] additional work is done to calculate the ELU.
194-
195-
ELU is similar to CPU utilization except that it is calculated using high
196-
precision wall-clock time. It represents the percentage of time the event loop
197-
has spent outside the event loop's event provider (e.g. `epoll_wait`). No other
198-
CPU idle time is taken into consideration. The following is an example of how
199-
a mostly idle process will have a high ELU.
200-
201-
<!-- eslint-skip -->
202-
```js
203-
'use strict';
204-
const { eventLoopUtilization } = require('perf_hooks').performance;
205-
const { spawnSync } = require('child_process');
206-
207-
setImmediate(() => {
208-
const elu = eventLoopUtilization();
209-
spawnSync('sleep', ['5']);
210-
console.log(eventLoopUtilization(elu).utilization);
211-
});
212-
```
213-
214-
While the CPU is mostly idle while running this script the value of
215-
`utilization` is 1. This is because the call to [`child_process.spawnSync()`][]
216-
blocks the event loop from proceeding.
217-
218-
Passing in a user-defined object instead of the result of a previous call to
219-
`eventLoopUtilization()` will lead to undefined behavior. The return values
220-
are not guaranteed to reflect any correct state of the event loop.
221-
222222
## Class: `PerformanceEntry`
223223
<!-- YAML
224224
added: v8.5.0
@@ -234,41 +234,54 @@ added: v8.5.0
234234
The total number of milliseconds elapsed for this entry. This value will not
235235
be meaningful for all Performance Entry types.
236236

237-
### `performanceEntry.name`
237+
### `performanceEntry.entryType`
238238
<!-- YAML
239239
added: v8.5.0
240240
-->
241241

242242
* {string}
243243

244-
The name of the performance entry.
244+
The type of the performance entry. It may be one of:
245245

246-
### `performanceEntry.startTime`
246+
* `'node'` (Node.js only)
247+
* `'mark'` (available on the Web)
248+
* `'measure'` (available on the Web)
249+
* `'gc'` (Node.js only)
250+
* `'function'` (Node.js only)
251+
* `'http2'` (Node.js only)
252+
* `'http'` (Node.js only)
253+
254+
### performanceEntry.flags
247255
<!-- YAML
248-
added: v8.5.0
256+
added:
257+
- v13.9.0
258+
- v12.17.0
249259
-->
250260

251261
* {number}
252262

253-
The high resolution millisecond timestamp marking the starting time of the
254-
Performance Entry.
263+
_This property is an extension by Node.js. It is not available in Web browsers._
255264

256-
### `performanceEntry.entryType`
265+
When `performanceEntry.entryType` is equal to `'gc'`, the `performance.flags`
266+
property contains additional information about garbage collection operation.
267+
The value may be one of:
268+
269+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_NO`
270+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED`
271+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_FORCED`
272+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING`
273+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE`
274+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY`
275+
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE`
276+
277+
### `performanceEntry.name`
257278
<!-- YAML
258279
added: v8.5.0
259280
-->
260281

261282
* {string}
262283

263-
The type of the performance entry. It may be one of:
264-
265-
* `'node'` (Node.js only)
266-
* `'mark'` (available on the Web)
267-
* `'measure'` (available on the Web)
268-
* `'gc'` (Node.js only)
269-
* `'function'` (Node.js only)
270-
* `'http2'` (Node.js only)
271-
* `'http'` (Node.js only)
284+
The name of the performance entry.
272285

273286
### `performanceEntry.kind`
274287
<!-- YAML
@@ -288,26 +301,15 @@ The value may be one of:
288301
* `perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL`
289302
* `perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB`
290303

291-
### performanceEntry.flags
304+
### `performanceEntry.startTime`
292305
<!-- YAML
293-
added: v13.9.0
306+
added: v8.5.0
294307
-->
295308

296309
* {number}
297310

298-
_This property is an extension by Node.js. It is not available in Web browsers._
299-
300-
When `performanceEntry.entryType` is equal to `'gc'`, the `performance.flags`
301-
property contains additional information about garbage collection operation.
302-
The value may be one of:
303-
304-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_NO`
305-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED`
306-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_FORCED`
307-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING`
308-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE`
309-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY`
310-
* `perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE`
311+
The high resolution millisecond timestamp marking the starting time of the
312+
Performance Entry.
311313

312314
## Class: `PerformanceNodeTiming extends PerformanceEntry`
313315
<!-- YAML
@@ -340,6 +342,19 @@ added: v8.5.0
340342
The high resolution millisecond timestamp at which the Node.js environment was
341343
initialized.
342344

345+
### `performanceNodeTiming.idleTime`
346+
<!-- YAML
347+
added: REPLACEME
348+
-->
349+
350+
* {number}
351+
352+
The high resolution millisecond timestamp of the amount of time the event loop
353+
has been idle within the event loop's event provider (e.g. `epoll_wait`). This
354+
does not take CPU usage into consideration. If the event loop has not yet
355+
started (e.g., in the first tick of the main script), the property has the
356+
value of 0.
357+
343358
### `performanceNodeTiming.loopExit`
344359
<!-- YAML
345360
added: v8.5.0
@@ -382,19 +397,6 @@ added: v8.5.0
382397
The high resolution millisecond timestamp at which the V8 platform was
383398
initialized.
384399

385-
### `performanceNodeTiming.idleTime`
386-
<!-- YAML
387-
added: REPLACEME
388-
-->
389-
390-
* {number}
391-
392-
The high resolution millisecond timestamp of the amount of time the event loop
393-
has been idle within the event loop's event provider (e.g. `epoll_wait`). This
394-
does not take CPU usage into consideration. If the event loop has not yet
395-
started (e.g., in the first tick of the main script), the property has the
396-
value of 0.
397-
398400
## Class: `perf_hooks.PerformanceObserver`
399401

400402
### `new PerformanceObserver(callback)`

0 commit comments

Comments
 (0)