From b8c88891a6907d176cb93873323a302be99d4ec8 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 1 May 2020 22:48:04 +0800 Subject: [PATCH] doc: clarify about the Node.js-only extensions in perf_hooks - Add clarifications for Node.js-only extensions - Explain the Web Performance APIs implemented in Node.js and clarify that perf_hooks also include other non-Web APIs. - Prefix exposed interfaces with `perf_hooks.` to distinguish them from internal classes. PR-URL: https://github.com/nodejs/node/pull/33199 Refs: https://github.com/nodejs/node/issues/28635 Reviewed-By: James M Snell Reviewed-By: Chengzhong Wu Reviewed-By: Rich Trott Reviewed-By: Ruben Bridgewater --- doc/api/perf_hooks.md | 60 ++++++++++++++++++++++++++++++++-------- tools/doc/type-parser.js | 2 +- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 4d37d0da26babf..20f0cc0c4bb89b 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -1,13 +1,18 @@ -# Performance Timing API +# Performance Measurement APIs > Stability: 2 - Stable -The Performance Timing API provides an implementation of the -[W3C Performance Timeline][] specification. The purpose of the API -is to support collection of high resolution performance metrics. -This is the same Performance API as implemented in modern Web browsers. +This module provides an implementation of a subset of the W3C +[Web Performance APIs][] as well as additional APIs for +Node.js-specific performance measurements. + +Node.js supports the following [Web Performance APIs][]: + +* [High Resolution Time][] +* [Performance Timeline][] +* [User Timing][] ```js const { PerformanceObserver, performance } = require('perf_hooks'); @@ -28,11 +33,14 @@ doSomeLongRunningProcess(() => { }); ``` -## Class: `Performance` +## `perf_hooks.performance` +An object that can be used to collect performance metrics from the current +Node.js instance. It is similar to [`window.performance`][] in browsers. + ### `performance.clearMarks([name])` -Provides timing details for Node.js itself. +_This property is an extension by Node.js. It is not available in Web browsers._ + +Provides timing details for Node.js itself. The constructor of this class +is not exposed to users. ### `performanceNodeTiming.bootstrapComplete` -Tracks the event loop delay at a given sampling rate. +Tracks the event loop delay at a given sampling rate. The constructor of +this class not exposed to users. + +_This property is an extension by Node.js. It is not available in Web browsers._ #### `histogram.disable()`