Перейти до вмісту

node:perf_hooks

Часова шкала продуктивності, спостерігачі та допоміжні засоби гістограм.

На цій сторінці

Модуль має спільні з веб-глобальними об’єктами Performance часову шкалу продуктивності та конструктори:

import { performance } from "node:perf_hooks";

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

Експорти: performance, now, допоміжні засоби mark/measure/query/clear, конструктори Performance, nodeTiming, createHistogram, monitorEventLoopDelay, eventLoopUtilization і timerify.

performance === globalThis.performance, а конструктори модуля — ті самі об’єкти, що й їхні глобальні відповідники. nodeTiming також входить до performance.getEntriesByType("node").

Примітки щодо сумісності

  • constants — порожній об’єкт.
  • nodeTiming повідомляє етапи запуску в мілісекундах відносно старту процесу; v8Start, environment, loopExit і idleTime дорівнюють нулю.

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.

Чи була ця сторінка корисною?