Skip to content

Performance

How Elide supports performance, PerformanceObserver and PerformanceEntry per the User Timing and Performance Timeline specs, shared with node:perf_hooks.

Read offlineelide help api-wintercg-performance

On this page

performance, PerformanceObserver, and the PerformanceEntry classes are globals and follow the User Timing and Performance Timeline specs.

Example

js
// performance.mjs
const start = performance.now();
performance.mark("parse:start");
JSON.parse(JSON.stringify(Array.from({ length: 1000 }, (_, i) => ({ i }))));
performance.mark("parse:end", { detail: { rows: 1000 } });

const measure = performance.measure("parse", "parse:start", "parse:end");
console.log(measure.entryType, measure.name, measure.duration >= 0);
console.log(performance.getEntriesByName("parse:end")[0].detail.rows);
console.log(performance.now() >= start, typeof performance.timeOrigin);
utf-8 · js · Lines: 10

elide run performance.mjs prints:

text
measure parse true
1000
true number
utf-8 · text · Lines: 3

Differences from browsers

  • performance and node:perf_hooks share one timeline.
  • PerformanceObserver.supportedEntryTypes is mark, measure, node, and function.
  • Mark and measure detail values are cloned as in Web Messaging; functions throw DataCloneError.

Reference

Status: Full · Not measured · since 1.1.0

Exports

Export Kind Status Notes
PerformanceEntry class Full name, entryType, startTime, duration, detail, toJSON()
PerformanceMark class Full detail
PerformanceMeasure class Full detail
PerformanceObserverEntryList class Full getEntries(), getEntriesByName(), getEntriesByType()
PerformanceObserver class Full observe(), disconnect(), takeRecords(), PerformanceObserver.supportedEntryTypes
Performance class Full now(), timeOrigin, mark(), measure(), getEntries(), getEntriesByName(), getEntriesByType(), clearMarks(), clearMeasures(), toJSON()

Was this page helpful?