Skip to content

Commit 51425a8

Browse files
committed
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 75d943e commit 51425a8

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

doc/api/perf_hooks.md

Lines changed: 102 additions & 102 deletions
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
@@ -165,62 +221,6 @@ obs.observe({ entryTypes: ['function'] });
165221
wrapped();
166222
```
167223

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

239-
### `performanceEntry.name`
239+
### `performanceEntry.entryType`
240240
<!-- YAML
241241
added: v8.5.0
242242
-->
243243

244244
* {string}
245245

246-
The name of the performance entry.
246+
The type of the performance entry. It may be one of:
247247

248-
### `performanceEntry.startTime`
248+
* `'node'` (Node.js only)
249+
* `'mark'` (available on the Web)
250+
* `'measure'` (available on the Web)
251+
* `'gc'` (Node.js only)
252+
* `'function'` (Node.js only)
253+
* `'http2'` (Node.js only)
254+
* `'http'` (Node.js only)
255+
256+
### performanceEntry.flags
249257
<!-- YAML
250-
added: v8.5.0
258+
added:
259+
- v13.9.0
260+
- v12.17.0
251261
-->
252262

253263
* {number}
254264

255-
The high resolution millisecond timestamp marking the starting time of the
256-
Performance Entry.
265+
_This property is an extension by Node.js. It is not available in Web browsers._
257266

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

263284
* {string}
264285

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

275288
### `performanceEntry.kind`
276289
<!-- YAML
@@ -290,28 +303,15 @@ The value may be one of:
290303
* `perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL`
291304
* `perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB`
292305

293-
### performanceEntry.flags
306+
### `performanceEntry.startTime`
294307
<!-- YAML
295-
added:
296-
- v13.9.0
297-
- v12.17.0
308+
added: v8.5.0
298309
-->
299310

300311
* {number}
301312

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

316316
## Class: `PerformanceNodeTiming`
317317
<!-- YAML
@@ -346,6 +346,19 @@ added: v8.5.0
346346
The high resolution millisecond timestamp at which the Node.js environment was
347347
initialized.
348348

349+
### `performanceNodeTiming.idleTime`
350+
<!-- YAML
351+
added: REPLACEME
352+
-->
353+
354+
* {number}
355+
356+
The high resolution millisecond timestamp of the amount of time the event loop
357+
has been idle within the event loop's event provider (e.g. `epoll_wait`). This
358+
does not take CPU usage into consideration. If the event loop has not yet
359+
started (e.g., in the first tick of the main script), the property has the
360+
value of 0.
361+
349362
### `performanceNodeTiming.loopExit`
350363
<!-- YAML
351364
added: v8.5.0
@@ -388,19 +401,6 @@ added: v8.5.0
388401
The high resolution millisecond timestamp at which the V8 platform was
389402
initialized.
390403

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

406406
### `new PerformanceObserver(callback)`

0 commit comments

Comments
 (0)