Performance

High-resolution timing, marks, measures, and observers.

The performance global and node:perf_hooks share one timeline.

Timing and entries

performance.now();        // milliseconds since timeOrigin
performance.mark("start");
performance.measure("work", "start");

performance.getEntriesByName("work")[0].entryType; // "measure"

getEntries(), getEntriesByName(), and getEntriesByType() return fresh arrays sorted by start time. clearMarks() and clearMeasures() remove matching entries.

PerformanceMark is constructible. Performance, PerformanceEntry, and PerformanceMeasure are not directly constructible.

PerformanceObserver

const observer = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    console.log(entry.name, entry.entryType);
  }
});

observer.observe({ entryTypes: ["mark", "measure"] });
performance.mark("ready");

Observer delivery occurs at a microtask checkpoint. disconnect() stops observation and clears buffered entries; takeRecords() drains the current buffer.

PerformanceObserver.supportedEntryTypes contains mark, measure, node, and function.

Mark and measure detail values use the same structured-clone behavior as Web Messaging. Types such as Date, RegExp, Map, Set, and ArrayBuffer retain their type and contents; functions throw DataCloneError.