Skip to main content

PerformanceObserver

全局 PerformanceObserver 类,如 Web 规范中定义。

¥The global PerformanceObserver class, as defined in Web specifications.

示例​

¥Example

ts
const observer = new PerformanceObserver(
(list, observer, options) => {
for (const entry of list.getEntries()) {
console.log(
'Received entry with type',
entry.entryType,
'and name',
entry.name,
'that started at',
entry.startTime,
'and took',
entry.duration,
'ms',
);
}
},
);

observer.observe({entryTypes: ['mark', 'measure']});

参考

¥Reference

构造函数​

¥Constructor

PerformanceObserver()​

参见 MDN 中的文档。

¥See documentation in MDN.

静态属性​

¥Static properties

supportedEntryTypes​

参见 MDN 中的文档。

¥See documentation in MDN.

返回 ['mark', 'measure', 'event', 'longtask']。

¥Returns ['mark', 'measure', 'event', 'longtask'].

实例方法​

¥Instance methods

observe()​

参见 MDN 中的文档。

¥See documentation in MDN.

disconnect()​

参见 MDN 中的文档。

¥See documentation in MDN.