تتشارك الوحدة خط الأداء الزمني والمُنشئات مع متغيرات 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
| 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. |
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.