1- # Performance Timing API
1+ # Performance Measurement APIs
22
33<!-- introduced_in=v8.5.0-->
44
55> Stability: 2 - Stable
66
7- The Performance Timing API provides an implementation of the
8- [ W3C Performance Timeline] [ ] specification. The purpose of the API
9- is to support collection of high resolution performance metrics.
10- This is the same Performance API as implemented in modern Web browsers.
7+ This module provides an implementation of a subset of the W3C
8+ [ Web Performance APIs] [ ] as well as additional APIs for
9+ Node.js-specific performance measurements.
10+
11+ Node.js supports the following [ Web Performance APIs] [ ] :
12+
13+ * [ High Resolution Time] [ ]
14+ * [ Performance Timeline] [ ]
15+ * [ User Timing] [ ]
1116
1217``` js
1318const { PerformanceObserver , performance } = require (' perf_hooks' );
@@ -28,11 +33,14 @@ doSomeLongRunningProcess(() => {
2833});
2934```
3035
31- ## Class: ` Performance `
36+ ## ` perf_hooks.performance `
3237<!-- YAML
3338added: v8.5.0
3439-->
3540
41+ An object that can be used to collect performance metrics from the current
42+ Node.js instance. It is similar to [ ` window.performance ` ] [ ] in browsers.
43+
3644### ` performance.clearMarks([name]) `
3745<!-- YAML
3846added: v8.5.0
@@ -93,6 +101,8 @@ added: v8.5.0
93101
94102* {PerformanceNodeTiming}
95103
104+ _ This property is an extension by Node.js. It is not available in Web browsers._
105+
96106An instance of the ` PerformanceNodeTiming ` class that provides performance
97107metrics for specific Node.js operational milestones.
98108
@@ -123,6 +133,8 @@ added: v8.5.0
123133
124134* ` fn ` {Function}
125135
136+ _ This property is an extension by Node.js. It is not available in Web browsers._
137+
126138Wraps a function within a new function that measures the running time of the
127139wrapped function. A ` PerformanceObserver ` must be subscribed to the ` 'function' `
128140event type in order for the timing details to be accessed.
@@ -190,8 +202,15 @@ added: v8.5.0
190202
191203* {string}
192204
193- The type of the performance entry. Currently it may be one of: ` 'node' ` ,
194- ` 'mark' ` , ` 'measure' ` , ` 'gc' ` , ` 'function' ` , ` 'http2' ` or ` 'http' ` .
205+ The type of the performance entry. It may be one of:
206+
207+ * ` 'node' ` (Node.js only)
208+ * ` 'mark' ` (available on the Web)
209+ * ` 'measure' ` (available on the Web)
210+ * ` 'gc' ` (Node.js only)
211+ * ` 'function' ` (Node.js only)
212+ * ` 'http2' ` (Node.js only)
213+ * ` 'http' ` (Node.js only)
195214
196215### ` performanceEntry.kind `
197216<!-- YAML
@@ -200,6 +219,8 @@ added: v8.5.0
200219
201220* {number}
202221
222+ _ This property is an extension by Node.js. It is not available in Web browsers._
223+
203224When ` performanceEntry.entryType ` is equal to ` 'gc' ` , the ` performance.kind `
204225property identifies the type of garbage collection operation that occurred.
205226The value may be one of:
@@ -216,6 +237,8 @@ added: v13.9.0
216237
217238* {number}
218239
240+ _ This property is an extension by Node.js. It is not available in Web browsers._
241+
219242When ` performanceEntry.entryType ` is equal to ` 'gc' ` , the ` performance.flags `
220243property contains additional information about garbage collection operation.
221244The value may be one of:
@@ -233,7 +256,10 @@ The value may be one of:
233256added: v8.5.0
234257-->
235258
236- Provides timing details for Node.js itself.
259+ _ This property is an extension by Node.js. It is not available in Web browsers._
260+
261+ Provides timing details for Node.js itself. The constructor of this class
262+ is not exposed to users.
237263
238264### ` performanceNodeTiming.bootstrapComplete `
239265<!-- YAML
@@ -298,7 +324,7 @@ added: v8.5.0
298324The high resolution millisecond timestamp at which the V8 platform was
299325initialized.
300326
301- ## Class: ` PerformanceObserver `
327+ ## Class: ` perf_hooks. PerformanceObserver`
302328
303329### ` new PerformanceObserver(callback) `
304330<!-- YAML
@@ -400,6 +426,7 @@ added: v8.5.0
400426
401427The ` PerformanceObserverEntryList ` class is used to provide access to the
402428` PerformanceEntry ` instances passed to a ` PerformanceObserver ` .
429+ The constructor of this class is not exposed to users.
403430
404431### ` performanceObserverEntryList.getEntries() `
405432<!-- YAML
@@ -447,6 +474,8 @@ added: v11.10.0
447474 than zero. ** Default:** ` 10 ` .
448475* Returns: {Histogram}
449476
477+ _ This property is an extension by Node.js. It is not available in Web browsers._
478+
450479Creates a ` Histogram ` object that samples and reports the event loop delay
451480over time. The delays will be reported in nanoseconds.
452481
@@ -475,7 +504,10 @@ console.log(h.percentile(99));
475504<!-- YAML
476505added: v11.10.0
477506-->
478- Tracks the event loop delay at a given sampling rate.
507+ Tracks the event loop delay at a given sampling rate. The constructor of
508+ this class not exposed to users.
509+
510+ _ This property is an extension by Node.js. It is not available in Web browsers._
479511
480512#### ` histogram.disable() `
481513<!-- YAML
@@ -649,5 +681,9 @@ require('some-module');
649681
650682[ `'exit'` ] : process.html#process_event_exit
651683[ `timeOrigin` ] : https://w3c.github.io/hr-time/#dom-performance-timeorigin
684+ [ `window.performance` ] : https://developer.mozilla.org/en-US/docs/Web/API/Window/performance
652685[ Async Hooks ] : async_hooks.html
653- [ W3C Performance Timeline ] : https://w3c.github.io/performance-timeline/
686+ [ High Resolution Time ] : https://www.w3.org/TR/hr-time-2
687+ [ Performance Timeline ] : https://w3c.github.io/performance-timeline/
688+ [ Web Performance APIs ] : https://w3c.github.io/perf-timing-primer/
689+ [ User Timing ] : https://www.w3.org/TR/user-timing/
0 commit comments