supportedEntryTypes: Array<string> = ["mark"
Returns an array of the entryType values supported by the user agent.
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"] });