Performance API
The PerformanceObserverEntryList interface is a list of PerformanceEntry that were explicitly observed via the PerformanceObserver.observe method.
Instance methods
- PerformanceObserverEntryList.getEntries
- : Returns a list of all explicitly observed PerformanceEntry objects.
- PerformanceObserverEntryList.getEntriesByType
- : Returns a list of all explicitly observed PerformanceEntry objects of the given entry type.
- PerformanceObserverEntryList.getEntriesByName
- : Returns a list of all explicitly observed PerformanceEntry objects based on the given name and entry type.
Examples
Using PerformanceObserverEntryList
In the following example, list is the PerformanceObserverEntryList object. The PerformanceObserverEntryList.getEntries method is called to get all explicitly observed PerformanceEntry objects which are "measure" and "mark" in this case.
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"] });
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
