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: add missing api entries on performance #42018

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
81 changes: 81 additions & 0 deletions doc/api/perf_hooks.md
Expand Up @@ -55,6 +55,17 @@ added: v8.5.0
If `name` is not provided, removes all `PerformanceMark` objects from the
Performance Timeline. If `name` is provided, removes only the named mark.

### `performance.clearMeasures([name])`

<!-- YAML
added: v16.7.0
-->

* `name` {string}

If `name` is not provided, removes all `PerformanceMeasure` objects from the
Performance Timeline. If `name` is provided, removes only the named mark.

### `performance.eventLoopUtilization([utilization1[, utilization2]])`

<!-- YAML
Expand Down Expand Up @@ -118,6 +129,47 @@ Passing in a user-defined object instead of the result of a previous call to
`eventLoopUtilization()` will lead to undefined behavior. The return values
are not guaranteed to reflect any correct state of the event loop.

### `performance.getEntries()`

<!-- YAML
added: v16.7.0
-->

* Returns: {PerformanceEntry\[]}

Returns a list of `PerformanceEntry` objects in chronological order with
respect to `performanceEntry.startTime`. If you are only interested in
performance entries of certain types or that have certain names, see
`performance.getEntriesByType()` and `performance.getEntriesByName()`.

### `performance.getEntriesByName(name[, type])`

<!-- YAML
added: v16.7.0
-->

* `name` {string}
* `type` {string}
* Returns: {PerformanceEntry\[]}

Returns a list of `PerformanceEntry` objects in chronological order
with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to
`type`.

### `performance.getEntriesByType(type)`

<!-- YAML
added: v16.7.0
-->

* `type` {string}
* Returns: {PerformanceEntry\[]}

Returns a list of `PerformanceEntry` objects in chronological order
with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`
is equal to `type`.

### `performance.mark([name[, options]])`

<!-- YAML
Expand All @@ -140,6 +192,12 @@ Creates a new `PerformanceMark` entry in the Performance Timeline. A
`performanceEntry.duration` is always `0`. Performance marks are used
to mark specific significant moments in the Performance Timeline.

The created `PerformanceMark` entry is put in the global performance timeline
legendecas marked this conversation as resolved.
Show resolved Hide resolved
and can be queries with `performance.getEntries`,
legendecas marked this conversation as resolved.
Show resolved Hide resolved
`performance.getEntriesByName`, and `performance.getEntriesByType`. When the
observation is performed, the entries should be cleared from the global
performance timeline manually with `performance.clearMarks`.
legendecas marked this conversation as resolved.
Show resolved Hide resolved

### `performance.measure(name[, startMarkOrOptions[, endMark]])`

<!-- YAML
Expand Down Expand Up @@ -183,6 +241,12 @@ in the Performance Timeline or any of the timestamp properties provided by the
if no parameter is passed, otherwise if the named `endMark` does not exist, an
error will be thrown.

The created `PerformanceMeasure` entry is put in the global performance timeline
legendecas marked this conversation as resolved.
Show resolved Hide resolved
and can be queries with `performance.getEntries`,
legendecas marked this conversation as resolved.
Show resolved Hide resolved
`performance.getEntriesByName`, and `performance.getEntriesByType`. When the
observation is performed, the entries should be cleared from the global
performance timeline manually with `performance.clearMeasures`.
legendecas marked this conversation as resolved.
Show resolved Hide resolved

### `performance.nodeTiming`

<!-- YAML
Expand Down Expand Up @@ -258,6 +322,9 @@ const wrapped = performance.timerify(someFunction);

const obs = new PerformanceObserver((list) => {
console.log(list.getEntries()[0].duration);

performance.clearMarks();
performance.clearMeasures();
obs.disconnect();
});
obs.observe({ entryTypes: ['function'] });
Expand Down Expand Up @@ -591,6 +658,9 @@ const {

const obs = new PerformanceObserver((list, observer) => {
console.log(list.getEntries());

performance.clearMarks();
performance.clearMeasures();
observer.disconnect();
});
obs.observe({ entryTypes: ['mark'], buffered: true });
Expand Down Expand Up @@ -706,6 +776,9 @@ const obs = new PerformanceObserver((perfObserverList, observer) => {
* }
* ]
*/

performance.clearMarks();
performance.clearMeasures();
observer.disconnect();
});
obs.observe({ type: 'mark' });
Expand Down Expand Up @@ -761,6 +834,9 @@ const obs = new PerformanceObserver((perfObserverList, observer) => {
* ]
*/
console.log(perfObserverList.getEntriesByName('test', 'measure')); // []

performance.clearMarks();
performance.clearMeasures();
observer.disconnect();
});
obs.observe({ entryTypes: ['mark', 'measure'] });
Expand Down Expand Up @@ -806,6 +882,8 @@ const obs = new PerformanceObserver((perfObserverList, observer) => {
* }
* ]
*/
performance.clearMarks();
performance.clearMeasures();
observer.disconnect();
});
obs.observe({ type: 'mark' });
Expand Down Expand Up @@ -1155,6 +1233,7 @@ hook.enable();
const obs = new PerformanceObserver((list, observer) => {
console.log(list.getEntries()[0]);
performance.clearMarks();
performance.clearMeasures();
observer.disconnect();
});
obs.observe({ entryTypes: ['measure'], buffered: true });
Expand Down Expand Up @@ -1188,6 +1267,8 @@ const obs = new PerformanceObserver((list) => {
entries.forEach((entry) => {
console.log(`require('${entry[0]}')`, entry.duration);
});
performance.clearMarks();
performance.clearMeasures();
obs.disconnect();
});
obs.observe({ entryTypes: ['function'], buffered: true });
Expand Down