Zum Inhalt springen

Diese Seite ist noch nicht übersetzt und wird auf Englisch angezeigt.

node:perf_hooks

How Elide supports Node's perf_hooks: it shares one timeline with the Web performance globals; constants is empty and resource timing is absent.

Offline lesenelide help --lang de api-node-perf-hooks

Auf dieser Seite

node:perf_hooks follows Node’s perf_hooks; its performance and constructors are the same objects as the Performance globals.

Example

js
// perf.mjs
import { PerformanceObserver, performance } from "node:perf_hooks";

const observer = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) console.log(entry.entryType, entry.name, entry.duration >= 0);
  observer.disconnect();
});
observer.observe({ entryTypes: ["measure"] });

performance.mark("start");
for (let i = 0; i < 1e5; i++);
performance.mark("end");
performance.measure("loop", "start", "end");
console.log(performance.getEntriesByType("mark").map((mark) => mark.name).join());
utf-8 · js · Lines: 14

elide run perf.mjs prints:

text
start,end
measure loop true
utf-8 · text · Lines: 2

Differences from Node

  • constants is an empty object.
  • PerformanceResourceTiming is absent.
  • nodeTiming.v8Start, environment, loopExit, and idleTime are zero.

Reference

Status: Partial · Not measured · since 1.1.0

Exports

Export Kind Status Notes
PerformanceEntry class Full name, entryType, startTime, duration, detail, toJSON()
PerformanceMark class Full
PerformanceMeasure class Full
PerformanceNodeTiming class Full nodeStart, v8Start, environment, bootstrapComplete, loopStart, loopExit, idleTime
PerformanceObserverEntryList class Full getEntries(), getEntriesByName(), getEntriesByType()
PerformanceObserver class Full observe(), disconnect(), takeRecords(), PerformanceObserver.supportedEntryTypes
now() function Full Returns the current high-resolution millisecond timestamp relative to timeOrigin
mark() function Full Creates a performance mark with the given name
measure() function Full Creates a performance measure between two marks or timestamps
getEntries() function Full Returns a list of all performance entries
getEntriesByName() function Full Returns performance entries filtered by name
getEntriesByType() function Full Returns performance entries filtered by type (“mark” or “measure”)
clearMarks() function Full Removes all marks, or only marks with the given name
clearMeasures() function Full Removes all measures, or only measures with the given name
timeOrigin property Full The high-resolution millisecond timestamp at which the process started
nodeTiming property Full Timing information about the Node.js process lifecycle

Not implemented

Performance, PerformanceResourceTiming.

War diese Seite hilfreich?