انتقل إلى المحتوى

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.

هل كانت هذه الصفحة مفيدة؟