From a3f0887ef41af6cc6fedadb643b1ce72814ddd64 Mon Sep 17 00:00:00 2001 From: kovan Date: Wed, 11 Mar 2026 00:52:45 +0100 Subject: [PATCH] doc: fix perf_hooks documentation gaps and inaccuracies - Fix introductory ESM example that references undefined `doSomeLongRunningProcess` and prematurely clears marks - Add missing PerformanceResourceTiming properties: initiatorType, nextHopProtocol, responseStart, deliveryType, responseStatus - Correct PerformanceMark/PerformanceMeasure version metadata from v18.2.0/v16.17.0 to v16.0.0 (introduced in PR #37136) - Fix histogram.exceeds description: it counts values exceeding the histogram's configured `highest` value, not a "1 hour" threshold - Generalize Histogram property descriptions (min, max, mean, stddev) to not reference "event loop delay" since Histogram is a generic class Fixes: https://github.com/nodejs/node/issues/40558 Fixes: https://github.com/nodejs/node/issues/40096 Fixes: https://github.com/nodejs/node/issues/40723 Fixes: https://github.com/nodejs/node/issues/55792 Fixes: https://github.com/nodejs/node/issues/55793 Co-Authored-By: Claude Opus 4.6 --- doc/api/perf_hooks.md | 120 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 97 insertions(+), 23 deletions(-) diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index bd38befcffbedc..83a05b5ebdc76f 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -22,18 +22,16 @@ import { performance, PerformanceObserver } from 'node:perf_hooks'; const obs = new PerformanceObserver((items) => { console.log(items.getEntries()[0].duration); - performance.clearMarks(); }); obs.observe({ type: 'measure' }); performance.measure('Start to Now'); performance.mark('A'); -doSomeLongRunningProcess(() => { - performance.measure('A to Now', 'A'); +await new Promise((r) => setTimeout(r, 5000)); +performance.measure('A to Now', 'A'); - performance.mark('B'); - performance.measure('A to B', 'A', 'B'); -}); +performance.mark('B'); +performance.measure('A to B', 'A', 'B'); ``` ```cjs @@ -511,9 +509,7 @@ Performance Entry. ## Class: `PerformanceMark` * Extends: {PerformanceEntry} @@ -538,9 +534,7 @@ Additional detail specified when creating with `Performance.mark()` method. ## Class: `PerformanceMeasure` * Extends: {PerformanceEntry} @@ -906,6 +900,24 @@ resources. The constructor of this class is not exposed to users directly. +### `performanceResourceTiming.initiatorType` + + + +* Type: {string} + +The string that represents the type of resource that initiated the +performance entry, such as `'fetch'`. + ### `performanceResourceTiming.workerStart` + +* Type: {string} + +A string representing the network protocol used to fetch the resource, as +identified by the [ALPN Protocol ID][]. When a proxy is used, if a tunnel +connection is established, this returns the ALPN Protocol ID of the tunneled +protocol. Otherwise, this returns the ALPN Protocol ID of the first hop to +the proxy. + ### `performanceResourceTiming.requestStart` + +* Type: {number} + +The high resolution millisecond timestamp representing the time immediately +after Node.js receives the first byte of the response from the server. ### `performanceResourceTiming.responseEnd` @@ -1164,6 +1215,28 @@ A number representing the size (in octets) received from the fetch (HTTP or cache), of the message body, after removing any applied content-codings. +### `performanceResourceTiming.deliveryType` + + + +* Type: {string} + +A string representing how the resource was delivered. For example, +resources delivered from the cache will return `'cache'`. + +### `performanceResourceTiming.responseStatus` + + + +* Type: {number} + +A number representing the HTTP response status code returned when +fetching the resource. + ### `performanceResourceTiming.toJSON()`