Mobserve
Bun

method

perf_hooks.PerformanceObserver.observe

options: { buffered: boolean; entryTypes: readonly EntryType[] } | { buffered: boolean; type: EntryType }
): void;

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}`);