Saltar al contenido

node:perf_hooks

Línea de tiempo de rendimiento, observadores y auxiliares de histogramas.

En esta página

El módulo comparte su línea de tiempo de rendimiento y sus constructores con los globales web de Performance:

import { performance } from "node:perf_hooks";

performance.mark("start");
performance.measure("work", "start");
console.log(performance.getEntriesByName("work").length); // 1

Las exportaciones incluyen performance, now, auxiliares de marca/medida/consulta/borrado, constructores de Performance, nodeTiming, createHistogram, monitorEventLoopDelay, eventLoopUtilization y timerify.

performance === globalThis.performance, y los constructores del módulo son los mismos objetos que sus equivalentes globales. nodeTiming también se incluye en performance.getEntriesByType("node").

Notas de compatibilidad

  • constants es un objeto vacío.
  • nodeTiming informa de los hitos de arranque en milisegundos relativos al inicio del proceso; v8Start, environment, loopExit e idleTime valen cero.

Reference

Status: Partial · Not measured · since 1.1.0

Exports

ExportKindStatusNotes
PerformanceEntryclassFullname, entryType, startTime, duration, detail, toJSON()
PerformanceMarkclassFull
PerformanceMeasureclassFull
PerformanceNodeTimingclassFullnodeStart, v8Start, environment, bootstrapComplete, loopStart, loopExit, idleTime
PerformanceObserverEntryListclassFullgetEntries(), getEntriesByName(), getEntriesByType()
PerformanceObserverclassFullobserve(), disconnect(), takeRecords(), PerformanceObserver.supportedEntryTypes
now()functionFullReturns the current high-resolution millisecond timestamp relative to timeOrigin
mark()functionFullCreates a performance mark with the given name
measure()functionFullCreates a performance measure between two marks or timestamps
getEntries()functionFullReturns a list of all performance entries
getEntriesByName()functionFullReturns performance entries filtered by name
getEntriesByType()functionFullReturns performance entries filtered by type (“mark” or “measure”)
clearMarks()functionFullRemoves all marks, or only marks with the given name
clearMeasures()functionFullRemoves all measures, or only measures with the given name
timeOriginpropertyFullThe high-resolution millisecond timestamp at which the process started
nodeTimingpropertyFullTiming information about the Node.js process lifecycle

Not implemented

Performance, PerformanceResourceTiming.

¿Te resultó útil esta página?