Documentation/PerformanceObserver
PerformanceObserver(callback)
Parameters
| Name | Type | Description |
callback | function | |
supportedEntryTypes: Array<string> = ["mark"
Returns an array of the entryType values supported by the user agent.
disconnect()
Stops the performance observer callback from receiving performance entries.
observe(options)
Specifies the set of entry types to observe.
The performance observer's callback function will be invoked when performance entry is recorded for one of the specified entryTypes.
Parameters
| Name | Type | Description |
options | Object | An object with the following possible members: entryTypes - An array of strings, each specifying one performance entry type to observe. May not be used together with the type type - A single string specifying exactly one performance entry type to observe. May not be used together with the entryTypes option. |
Example
function perfObserver(list, observer) {
list.getEntries().forEach((entry) => {
if (entry.entryType === "mark") {
console.log(`${entry.name}'s startTime: ${entry.startTime}`);
}
if (entry.entryType === "measure") {
console.log(`${entry.name}'s duration: ${entry.duration}`);
}
});
}
const observer = new PerformanceObserver(perfObserver);
observer.observe({ entryTypes: ["measure", "mark"] });
takeRecords()
Returns the current list of performance entries stored in the performance observer, emptying it out.