class PerformanceObserver
extends AsyncResource
Constructors Jump to heading
new
Jump to headingPerformanceObserver(callback: PerformanceObserverCallback)Methods Jump to heading
Jump to headingdisconnect(): voidDisconnects the PerformanceObserver instance from all notifications.
Jump to headingobserve(options: { entryTypes: readonly EntryType[]; buffered?: boolean | undefined; } | { type: EntryType; buffered?: boolean | undefined; }): voidSubscribes 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}`);