PerformanceObserverEntryList
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
Giao diện PerformanceObserverEntryList là danh sách các sự kiện hiệu suất được quan sát rõ ràng thông qua phương thức observe().
Phương thức phiên bản
PerformanceObserverEntryList.getEntries()-
Trả về danh sách tất cả các đối tượng
PerformanceEntryđược quan sát rõ ràng. PerformanceObserverEntryList.getEntriesByType()-
Trả về danh sách tất cả các đối tượng
PerformanceEntryđược quan sát rõ ràng thuộc loại mục nhập đã cho. PerformanceObserverEntryList.getEntriesByName()-
Trả về danh sách tất cả các đối tượng
PerformanceEntryđược quan sát rõ ràng dựa trên tên và loại mục nhập đã cho.
Ví dụ
>Sử dụng PerformanceObserverEntryList
Trong ví dụ sau, list là đối tượng PerformanceObserverEntryList. Phương thức getEntries() được gọi để lấy tất cả các đối tượng PerformanceEntry được quan sát rõ ràng là "measure" và "mark" trong trường hợp này.
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"] });
Thông số kỹ thuật
| Specification |
|---|
| Performance Timeline> # performanceobserverentrylist-interface> |