performanceObserver.observe(options)


版本历史
版本变更
v16.7.0

已更新以符合性能时间轴级别 2。缓冲选项已被添加回来。

v16.0.0

已更新以符合用户计时级别 3。已删除缓冲选项。

v8.5.0

新增于: v8.5.0

  • options <Object>

    • type <string> 单个 <PerformanceEntry> 类型。如果已经指定了 entryTypes,则不能给出。

      \type <string> A single <PerformanceEntry> type. Must not be given if entryTypes is already specified.

    • entryTypes <string[]> 标识监视器感兴趣的 <PerformanceEntry> 实例类型的字符串数组。如果未提供,将抛出错误。

      \entryTypes <string[]> An array of strings identifying the types of <PerformanceEntry> instances the observer is interested in. If not provided an error will be thrown.

    • buffered <boolean> 如果为 true,则使用列表全局 PerformanceEntry 缓冲条目调用监视器回调。如果为 false,则只有在该时间点之后创建的 PerformanceEntry 被发送到监视器回调。默认值:false

      \buffered <boolean> If true, the observer callback is called with a list global PerformanceEntry buffered entries. If false, only PerformanceEntrys created after the time point are sent to the observer callback. Default: false.

<PerformanceObserver> 实例订阅由 options.entryTypesoptions.type 标识的新 <PerformanceEntry> 实例的通知:

\Subscribes the <PerformanceObserver> instance to notifications of new <PerformanceEntry> instances identified either by options.entryTypes or options.type:

import { performance, PerformanceObserver } from 'node:perf_hooks';
const obs = new PerformanceObserver((list, observer) => {
 // Called once asynchronously. `list` contains three items.
});
obs.observe({ type: 'mark' });
for (let n = 0; n < 3; n++)
 performance.mark(`test${n}`);const {
 performance,
 PerformanceObserver,
} = require('node:perf_hooks');
const obs = new PerformanceObserver((list, observer) => {
 // Called once asynchronously. `list` contains three items.
});
obs.observe({ type: 'mark' });
for (let n = 0; n < 3; n++)
 performance.mark(`test${n}`);

AltStyle によって変換されたページ (->オリジナル) /