Aller au contenu

node:perf_hooks

Chronologie des performances, observateurs et utilitaires d'histogrammes.

Sur cette page

Le module partage sa chronologie des performances et ses constructeurs avec les globales Performance du Web :

import { performance } from "node:perf_hooks";

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

Les exports comprennent performance, now, les utilitaires de marque, de mesure, de requête et d’effacement, les constructeurs Performance, nodeTiming, createHistogram, monitorEventLoopDelay, eventLoopUtilization et timerify.

performance === globalThis.performance, et les constructeurs du module ont la même identité que leurs équivalents globaux. nodeTiming figure aussi dans performance.getEntriesByType("node").

Notes de compatibilité

  • constants est un objet vide.
  • nodeTiming indique les jalons du démarrage en millisecondes par rapport au démarrage du processus ; v8Start, environment, loopExit et idleTime valent zéro.

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.

Cette page vous a-t-elle aidé ?