@types/node 24.10.3 → 25.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node v24.10/README.md → node/README.md +2 -2
- node v24.10/assert/strict.d.ts → node/assert/strict.d.ts +5 -11
- node v24.10/assert.d.ts → node/assert.d.ts +9 -169
- node v24.10/async_hooks.d.ts → node/async_hooks.d.ts +8 -8
- node v24.10/buffer.buffer.d.ts → node/buffer.buffer.d.ts +1 -7
- node v24.10/buffer.d.ts → node/buffer.d.ts +44 -168
- node v24.10/child_process.d.ts → node/child_process.d.ts +16 -64
- node/cluster.d.ts +486 -0
- node/console.d.ts +151 -0
- node v24.10/constants.d.ts → node/constants.d.ts +3 -4
- node v24.10/crypto.d.ts → node/crypto.d.ts +279 -1631
- node v24.10/dgram.d.ts → node/dgram.d.ts +15 -51
- node v24.10/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +4 -4
- node v24.10/dns/promises.d.ts → node/dns/promises.d.ts +3 -3
- node v24.10/dns.d.ts → node/dns.d.ts +131 -132
- node v24.10/domain.d.ts → node/domain.d.ts +13 -17
- node/events.d.ts +1046 -0
- node v24.10/fs/promises.d.ts → node/fs/promises.d.ts +7 -8
- node v24.10/fs.d.ts → node/fs.d.ts +417 -455
- node v24.10/globals.d.ts → node/globals.d.ts +6 -26
- node/globals.typedarray.d.ts +101 -0
- node v24.10/http.d.ts → node/http.d.ts +263 -254
- node v24.10/http2.d.ts → node/http2.d.ts +528 -804
- node v24.10/https.d.ts → node/https.d.ts +59 -239
- node v24.10/index.d.ts → node/index.d.ts +15 -1
- node/inspector/promises.d.ts +41 -0
- node v24.10/inspector.d.ts → node/inspector.d.ts +6 -59
- node v24.10/inspector.generated.d.ts → node/inspector.generated.d.ts +3 -10
- node v24.10/module.d.ts → node/module.d.ts +47 -122
- node v24.10/net.d.ts → node/net.d.ts +63 -184
- node v24.10/os.d.ts → node/os.d.ts +6 -6
- node v24.10/package.json → node/package.json +2 -2
- node/path/posix.d.ts +8 -0
- node/path/win32.d.ts +8 -0
- node/path.d.ts +187 -0
- node/perf_hooks.d.ts +621 -0
- node v24.10/process.d.ts → node/process.d.ts +151 -128
- node v24.10/punycode.d.ts → node/punycode.d.ts +5 -5
- node v24.10/querystring.d.ts → node/querystring.d.ts +4 -4
- node/quic.d.ts +910 -0
- node v24.10/readline/promises.d.ts → node/readline/promises.d.ts +3 -3
- node v24.10/readline.d.ts → node/readline.d.ts +67 -120
- node v24.10/repl.d.ts → node/repl.d.ts +75 -98
- node v24.10/sea.d.ts → node/sea.d.ts +1 -1
- node v24.10/sqlite.d.ts → node/sqlite.d.ts +2 -2
- node v24.10/stream/consumers.d.ts → node/stream/consumers.d.ts +10 -10
- node/stream/promises.d.ts +211 -0
- node/stream/web.d.ts +296 -0
- node v24.10/stream.d.ts → node/stream.d.ts +555 -478
- node v24.10/string_decoder.d.ts → node/string_decoder.d.ts +4 -4
- node/test/reporters.d.ts +96 -0
- node v24.10/test.d.ts → node/test.d.ts +80 -180
- node v24.10/timers/promises.d.ts → node/timers/promises.d.ts +4 -4
- node v24.10/timers.d.ts → node/timers.d.ts +4 -130
- node v24.10/tls.d.ts → node/tls.d.ts +102 -177
- node v24.10/trace_events.d.ts → node/trace_events.d.ts +9 -9
- node v24.10/ts5.6/buffer.buffer.d.ts → node/ts5.6/buffer.buffer.d.ts +1 -7
- node v24.10/ts5.6/index.d.ts → node/ts5.6/index.d.ts +15 -1
- node v24.10/ts5.7/index.d.ts → node/ts5.7/index.d.ts +15 -1
- node v24.10/tty.d.ts → node/tty.d.ts +58 -16
- node/url.d.ts +519 -0
- node/util/types.d.ts +558 -0
- node v24.10/util.d.ts → node/util.d.ts +120 -792
- node v24.10/v8.d.ts → node/v8.d.ts +32 -5
- node v24.10/vm.d.ts → node/vm.d.ts +13 -13
- node v24.10/wasi.d.ts → node/wasi.d.ts +4 -4
- node v24.10/web-globals/abortcontroller.d.ts → node/web-globals/abortcontroller.d.ts +27 -2
- node/web-globals/blob.d.ts +23 -0
- node/web-globals/console.d.ts +9 -0
- node v24.10/web-globals/crypto.d.ts → node/web-globals/crypto.d.ts +7 -0
- node/web-globals/encoding.d.ts +11 -0
- node v24.10/web-globals/events.d.ts → node/web-globals/events.d.ts +9 -0
- node v24.10/web-globals/fetch.d.ts → node/web-globals/fetch.d.ts +4 -0
- node/web-globals/importmeta.d.ts +13 -0
- node/web-globals/messaging.d.ts +23 -0
- node/web-globals/performance.d.ts +45 -0
- node/web-globals/streams.d.ts +115 -0
- node/web-globals/timers.d.ts +44 -0
- node/web-globals/url.d.ts +24 -0
- node v24.10/worker_threads.d.ts → node/worker_threads.d.ts +176 -358
- node v24.10/zlib.d.ts → node/zlib.d.ts +8 -71
- node v24.10/cluster.d.ts +0 -578
- node v24.10/console.d.ts +0 -453
- node v24.10/events.d.ts +0 -976
- node v24.10/globals.typedarray.d.ts +0 -41
- node v24.10/path.d.ts +0 -200
- node v24.10/perf_hooks.d.ts +0 -982
- node v24.10/stream/promises.d.ts +0 -90
- node v24.10/stream/web.d.ts +0 -573
- node v24.10/url.d.ts +0 -1057
- node v24.10/web-globals/streams.d.ts +0 -22
- {node v24.10 → node}/LICENSE +0 -0
- {node v24.10 → node}/compatibility/iterators.d.ts +0 -0
- {node v24.10 → node}/ts5.6/compatibility/float16array.d.ts +0 -0
- {node v24.10 → node}/ts5.6/globals.typedarray.d.ts +0 -0
- {node v24.10 → node}/ts5.7/compatibility/float16array.d.ts +0 -0
- {node v24.10 → node}/web-globals/domexception.d.ts +0 -0
- {node v24.10 → node}/web-globals/navigator.d.ts +0 -0
- {node v24.10 → node}/web-globals/storage.d.ts +0 -0
node/perf_hooks.d.ts
ADDED
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
|
|
3
|
+
* Node.js-specific performance measurements.
|
|
4
|
+
*
|
|
5
|
+
* Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
|
|
6
|
+
*
|
|
7
|
+
* * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
|
|
8
|
+
* * [Performance Timeline](https://w3c.github.io/performance-timeline/)
|
|
9
|
+
* * [User Timing](https://www.w3.org/TR/user-timing/)
|
|
10
|
+
* * [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* import { PerformanceObserver, performance } from 'node:perf_hooks';
|
|
14
|
+
*
|
|
15
|
+
* const obs = new PerformanceObserver((items) => {
|
|
16
|
+
* console.log(items.getEntries()[0].duration);
|
|
17
|
+
* performance.clearMarks();
|
|
18
|
+
* });
|
|
19
|
+
* obs.observe({ type: 'measure' });
|
|
20
|
+
* performance.measure('Start to Now');
|
|
21
|
+
*
|
|
22
|
+
* performance.mark('A');
|
|
23
|
+
* doSomeLongRunningProcess(() => {
|
|
24
|
+
* performance.measure('A to Now', 'A');
|
|
25
|
+
*
|
|
26
|
+
* performance.mark('B');
|
|
27
|
+
* performance.measure('A to B', 'A', 'B');
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/perf_hooks.js)
|
|
31
|
+
*/
|
|
32
|
+
declare module "node:perf_hooks" {
|
|
33
|
+
import { InternalEventTargetEventProperties } from "node:events";
|
|
34
|
+
// #region web types
|
|
35
|
+
type EntryType =
|
|
36
|
+
| "dns" // Node.js only
|
|
37
|
+
| "function" // Node.js only
|
|
38
|
+
| "gc" // Node.js only
|
|
39
|
+
| "http2" // Node.js only
|
|
40
|
+
| "http" // Node.js only
|
|
41
|
+
| "mark" // available on the Web
|
|
42
|
+
| "measure" // available on the Web
|
|
43
|
+
| "net" // Node.js only
|
|
44
|
+
| "node" // Node.js only
|
|
45
|
+
| "resource"; // available on the Web
|
|
46
|
+
interface EventLoopUtilization {
|
|
47
|
+
idle: number;
|
|
48
|
+
active: number;
|
|
49
|
+
utilization: number;
|
|
50
|
+
}
|
|
51
|
+
interface ConnectionTimingInfo {
|
|
52
|
+
domainLookupStartTime: number;
|
|
53
|
+
domainLookupEndTime: number;
|
|
54
|
+
connectionStartTime: number;
|
|
55
|
+
connectionEndTime: number;
|
|
56
|
+
secureConnectionStartTime: number;
|
|
57
|
+
ALPNNegotiatedProtocol: string;
|
|
58
|
+
}
|
|
59
|
+
interface FetchTimingInfo {
|
|
60
|
+
startTime: number;
|
|
61
|
+
redirectStartTime: number;
|
|
62
|
+
redirectEndTime: number;
|
|
63
|
+
postRedirectStartTime: number;
|
|
64
|
+
finalServiceWorkerStartTime: number;
|
|
65
|
+
finalNetworkRequestStartTime: number;
|
|
66
|
+
finalNetworkResponseStartTime: number;
|
|
67
|
+
endTime: number;
|
|
68
|
+
finalConnectionTimingInfo: ConnectionTimingInfo | null;
|
|
69
|
+
encodedBodySize: number;
|
|
70
|
+
decodedBodySize: number;
|
|
71
|
+
}
|
|
72
|
+
type PerformanceEntryList = PerformanceEntry[];
|
|
73
|
+
interface PerformanceMarkOptions {
|
|
74
|
+
detail?: any;
|
|
75
|
+
startTime?: number;
|
|
76
|
+
}
|
|
77
|
+
interface PerformanceMeasureOptions {
|
|
78
|
+
detail?: any;
|
|
79
|
+
duration?: number;
|
|
80
|
+
end?: string | number;
|
|
81
|
+
start?: string | number;
|
|
82
|
+
}
|
|
83
|
+
interface PerformanceObserverCallback {
|
|
84
|
+
(entries: PerformanceObserverEntryList, observer: PerformanceObserver): void;
|
|
85
|
+
}
|
|
86
|
+
interface PerformanceObserverInit {
|
|
87
|
+
buffered?: boolean;
|
|
88
|
+
entryTypes?: EntryType[];
|
|
89
|
+
type?: EntryType;
|
|
90
|
+
}
|
|
91
|
+
interface PerformanceEventMap {
|
|
92
|
+
"resourcetimingbufferfull": Event;
|
|
93
|
+
}
|
|
94
|
+
interface Performance extends EventTarget, InternalEventTargetEventProperties<PerformanceEventMap> {
|
|
95
|
+
readonly nodeTiming: PerformanceNodeTiming;
|
|
96
|
+
readonly timeOrigin: number;
|
|
97
|
+
clearMarks(markName?: string): void;
|
|
98
|
+
clearMeasures(measureName?: string): void;
|
|
99
|
+
clearResourceTimings(resourceTimingName?: string): void;
|
|
100
|
+
getEntries(): PerformanceEntryList;
|
|
101
|
+
getEntriesByName(name: string, type?: EntryType): PerformanceEntryList;
|
|
102
|
+
getEntriesByType(type: EntryType): PerformanceEntryList;
|
|
103
|
+
mark(markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark;
|
|
104
|
+
markResourceTiming(
|
|
105
|
+
timingInfo: FetchTimingInfo,
|
|
106
|
+
requestedUrl: string,
|
|
107
|
+
initiatorType: string,
|
|
108
|
+
global: unknown,
|
|
109
|
+
cacheMode: string,
|
|
110
|
+
bodyInfo: unknown,
|
|
111
|
+
responseStatus: number,
|
|
112
|
+
deliveryType?: string,
|
|
113
|
+
): PerformanceResourceTiming;
|
|
114
|
+
measure(measureName: string, startMark?: string, endMark?: string): PerformanceMeasure;
|
|
115
|
+
measure(measureName: string, options: PerformanceMeasureOptions, endMark?: string): PerformanceMeasure;
|
|
116
|
+
now(): number;
|
|
117
|
+
setResourceTimingBufferSize(maxSize: number): void;
|
|
118
|
+
toJSON(): any;
|
|
119
|
+
addEventListener<K extends keyof PerformanceEventMap>(
|
|
120
|
+
type: K,
|
|
121
|
+
listener: (ev: PerformanceEventMap[K]) => void,
|
|
122
|
+
options?: AddEventListenerOptions | boolean,
|
|
123
|
+
): void;
|
|
124
|
+
addEventListener(
|
|
125
|
+
type: string,
|
|
126
|
+
listener: EventListener | EventListenerObject,
|
|
127
|
+
options?: AddEventListenerOptions | boolean,
|
|
128
|
+
): void;
|
|
129
|
+
removeEventListener<K extends keyof PerformanceEventMap>(
|
|
130
|
+
type: K,
|
|
131
|
+
listener: (ev: PerformanceEventMap[K]) => void,
|
|
132
|
+
options?: EventListenerOptions | boolean,
|
|
133
|
+
): void;
|
|
134
|
+
removeEventListener(
|
|
135
|
+
type: string,
|
|
136
|
+
listener: EventListener | EventListenerObject,
|
|
137
|
+
options?: EventListenerOptions | boolean,
|
|
138
|
+
): void;
|
|
139
|
+
/**
|
|
140
|
+
* The `eventLoopUtilization()` method returns an object that contains the
|
|
141
|
+
* cumulative duration of time the event loop has been both idle and active as a
|
|
142
|
+
* high resolution milliseconds timer. The `utilization` value is the calculated
|
|
143
|
+
* Event Loop Utilization (ELU).
|
|
144
|
+
*
|
|
145
|
+
* If bootstrapping has not yet finished on the main thread the properties have
|
|
146
|
+
* the value of `0`. The ELU is immediately available on [Worker threads](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html#worker-threads) since
|
|
147
|
+
* bootstrap happens within the event loop.
|
|
148
|
+
*
|
|
149
|
+
* Both `utilization1` and `utilization2` are optional parameters.
|
|
150
|
+
*
|
|
151
|
+
* If `utilization1` is passed, then the delta between the current call's `active`
|
|
152
|
+
* and `idle` times, as well as the corresponding `utilization` value are
|
|
153
|
+
* calculated and returned (similar to `process.hrtime()`).
|
|
154
|
+
*
|
|
155
|
+
* If `utilization1` and `utilization2` are both passed, then the delta is
|
|
156
|
+
* calculated between the two arguments. This is a convenience option because,
|
|
157
|
+
* unlike `process.hrtime()`, calculating the ELU is more complex than a
|
|
158
|
+
* single subtraction.
|
|
159
|
+
*
|
|
160
|
+
* ELU is similar to CPU utilization, except that it only measures event loop
|
|
161
|
+
* statistics and not CPU usage. It represents the percentage of time the event
|
|
162
|
+
* loop has spent outside the event loop's event provider (e.g. `epoll_wait`).
|
|
163
|
+
* No other CPU idle time is taken into consideration. The following is an example
|
|
164
|
+
* of how a mostly idle process will have a high ELU.
|
|
165
|
+
*
|
|
166
|
+
* ```js
|
|
167
|
+
* import { eventLoopUtilization } from 'node:perf_hooks';
|
|
168
|
+
* import { spawnSync } from 'node:child_process';
|
|
169
|
+
*
|
|
170
|
+
* setImmediate(() => {
|
|
171
|
+
* const elu = eventLoopUtilization();
|
|
172
|
+
* spawnSync('sleep', ['5']);
|
|
173
|
+
* console.log(eventLoopUtilization(elu).utilization);
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* Although the CPU is mostly idle while running this script, the value of
|
|
178
|
+
* `utilization` is `1`. This is because the call to
|
|
179
|
+
* `child_process.spawnSync()` blocks the event loop from proceeding.
|
|
180
|
+
*
|
|
181
|
+
* Passing in a user-defined object instead of the result of a previous call to
|
|
182
|
+
* `eventLoopUtilization()` will lead to undefined behavior. The return values
|
|
183
|
+
* are not guaranteed to reflect any correct state of the event loop.
|
|
184
|
+
* @since v14.10.0, v12.19.0
|
|
185
|
+
* @param utilization1 The result of a previous call to
|
|
186
|
+
* `eventLoopUtilization()`.
|
|
187
|
+
* @param utilization2 The result of a previous call to
|
|
188
|
+
* `eventLoopUtilization()` prior to `utilization1`.
|
|
189
|
+
*/
|
|
190
|
+
eventLoopUtilization(
|
|
191
|
+
utilization1?: EventLoopUtilization,
|
|
192
|
+
utilization2?: EventLoopUtilization,
|
|
193
|
+
): EventLoopUtilization;
|
|
194
|
+
/**
|
|
195
|
+
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
196
|
+
*
|
|
197
|
+
* Wraps a function within a new function that measures the running time of the
|
|
198
|
+
* wrapped function. A `PerformanceObserver` must be subscribed to the `'function'`
|
|
199
|
+
* event type in order for the timing details to be accessed.
|
|
200
|
+
*
|
|
201
|
+
* ```js
|
|
202
|
+
* import { performance, PerformanceObserver } from 'node:perf_hooks';
|
|
203
|
+
*
|
|
204
|
+
* function someFunction() {
|
|
205
|
+
* console.log('hello world');
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* const wrapped = performance.timerify(someFunction);
|
|
209
|
+
*
|
|
210
|
+
* const obs = new PerformanceObserver((list) => {
|
|
211
|
+
* console.log(list.getEntries()[0].duration);
|
|
212
|
+
*
|
|
213
|
+
* performance.clearMarks();
|
|
214
|
+
* performance.clearMeasures();
|
|
215
|
+
* obs.disconnect();
|
|
216
|
+
* });
|
|
217
|
+
* obs.observe({ entryTypes: ['function'] });
|
|
218
|
+
*
|
|
219
|
+
* // A performance timeline entry will be created
|
|
220
|
+
* wrapped();
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* If the wrapped function returns a promise, a finally handler will be attached
|
|
224
|
+
* to the promise and the duration will be reported once the finally handler is
|
|
225
|
+
* invoked.
|
|
226
|
+
* @since v8.5.0
|
|
227
|
+
*/
|
|
228
|
+
timerify<T extends (...args: any[]) => any>(fn: T, options?: PerformanceTimerifyOptions): T;
|
|
229
|
+
}
|
|
230
|
+
var Performance: {
|
|
231
|
+
prototype: Performance;
|
|
232
|
+
new(): Performance;
|
|
233
|
+
};
|
|
234
|
+
interface PerformanceEntry {
|
|
235
|
+
readonly duration: number;
|
|
236
|
+
readonly entryType: EntryType;
|
|
237
|
+
readonly name: string;
|
|
238
|
+
readonly startTime: number;
|
|
239
|
+
toJSON(): any;
|
|
240
|
+
}
|
|
241
|
+
var PerformanceEntry: {
|
|
242
|
+
prototype: PerformanceEntry;
|
|
243
|
+
new(): PerformanceEntry;
|
|
244
|
+
};
|
|
245
|
+
interface PerformanceMark extends PerformanceEntry {
|
|
246
|
+
readonly detail: any;
|
|
247
|
+
readonly entryType: "mark";
|
|
248
|
+
}
|
|
249
|
+
var PerformanceMark: {
|
|
250
|
+
prototype: PerformanceMark;
|
|
251
|
+
new(markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark;
|
|
252
|
+
};
|
|
253
|
+
interface PerformanceMeasure extends PerformanceEntry {
|
|
254
|
+
readonly detail: any;
|
|
255
|
+
readonly entryType: "measure";
|
|
256
|
+
}
|
|
257
|
+
var PerformanceMeasure: {
|
|
258
|
+
prototype: PerformanceMeasure;
|
|
259
|
+
new(): PerformanceMeasure;
|
|
260
|
+
};
|
|
261
|
+
interface PerformanceObserver {
|
|
262
|
+
disconnect(): void;
|
|
263
|
+
observe(options: PerformanceObserverInit): void;
|
|
264
|
+
takeRecords(): PerformanceEntryList;
|
|
265
|
+
}
|
|
266
|
+
var PerformanceObserver: {
|
|
267
|
+
prototype: PerformanceObserver;
|
|
268
|
+
new(callback: PerformanceObserverCallback): PerformanceObserver;
|
|
269
|
+
readonly supportedEntryTypes: readonly EntryType[];
|
|
270
|
+
};
|
|
271
|
+
interface PerformanceObserverEntryList {
|
|
272
|
+
getEntries(): PerformanceEntryList;
|
|
273
|
+
getEntriesByName(name: string, type?: EntryType): PerformanceEntryList;
|
|
274
|
+
getEntriesByType(type: EntryType): PerformanceEntryList;
|
|
275
|
+
}
|
|
276
|
+
var PerformanceObserverEntryList: {
|
|
277
|
+
prototype: PerformanceObserverEntryList;
|
|
278
|
+
new(): PerformanceObserverEntryList;
|
|
279
|
+
};
|
|
280
|
+
interface PerformanceResourceTiming extends PerformanceEntry {
|
|
281
|
+
readonly connectEnd: number;
|
|
282
|
+
readonly connectStart: number;
|
|
283
|
+
readonly decodedBodySize: number;
|
|
284
|
+
readonly domainLookupEnd: number;
|
|
285
|
+
readonly domainLookupStart: number;
|
|
286
|
+
readonly encodedBodySize: number;
|
|
287
|
+
readonly entryType: "resource";
|
|
288
|
+
readonly fetchStart: number;
|
|
289
|
+
readonly initiatorType: string;
|
|
290
|
+
readonly nextHopProtocol: string;
|
|
291
|
+
readonly redirectEnd: number;
|
|
292
|
+
readonly redirectStart: number;
|
|
293
|
+
readonly requestStart: number;
|
|
294
|
+
readonly responseEnd: number;
|
|
295
|
+
readonly responseStart: number;
|
|
296
|
+
readonly responseStatus: number;
|
|
297
|
+
readonly secureConnectionStart: number;
|
|
298
|
+
readonly transferSize: number;
|
|
299
|
+
readonly workerStart: number;
|
|
300
|
+
toJSON(): any;
|
|
301
|
+
}
|
|
302
|
+
var PerformanceResourceTiming: {
|
|
303
|
+
prototype: PerformanceResourceTiming;
|
|
304
|
+
new(): PerformanceResourceTiming;
|
|
305
|
+
};
|
|
306
|
+
var performance: Performance;
|
|
307
|
+
// #endregion
|
|
308
|
+
interface PerformanceTimerifyOptions {
|
|
309
|
+
/**
|
|
310
|
+
* A histogram object created using
|
|
311
|
+
* `perf_hooks.createHistogram()` that will record runtime durations in
|
|
312
|
+
* nanoseconds.
|
|
313
|
+
*/
|
|
314
|
+
histogram?: RecordableHistogram | undefined;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* _This class is an extension by Node.js. It is not available in Web browsers._
|
|
318
|
+
*
|
|
319
|
+
* Provides detailed Node.js timing data.
|
|
320
|
+
*
|
|
321
|
+
* The constructor of this class is not exposed to users directly.
|
|
322
|
+
* @since v19.0.0
|
|
323
|
+
*/
|
|
324
|
+
class PerformanceNodeEntry extends PerformanceEntry {
|
|
325
|
+
/**
|
|
326
|
+
* Additional detail specific to the `entryType`.
|
|
327
|
+
* @since v16.0.0
|
|
328
|
+
*/
|
|
329
|
+
readonly detail: any;
|
|
330
|
+
readonly entryType: "dns" | "function" | "gc" | "http2" | "http" | "net" | "node";
|
|
331
|
+
}
|
|
332
|
+
interface UVMetrics {
|
|
333
|
+
/**
|
|
334
|
+
* Number of event loop iterations.
|
|
335
|
+
*/
|
|
336
|
+
readonly loopCount: number;
|
|
337
|
+
/**
|
|
338
|
+
* Number of events that have been processed by the event handler.
|
|
339
|
+
*/
|
|
340
|
+
readonly events: number;
|
|
341
|
+
/**
|
|
342
|
+
* Number of events that were waiting to be processed when the event provider was called.
|
|
343
|
+
*/
|
|
344
|
+
readonly eventsWaiting: number;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
348
|
+
*
|
|
349
|
+
* Provides timing details for Node.js itself. The constructor of this class
|
|
350
|
+
* is not exposed to users.
|
|
351
|
+
* @since v8.5.0
|
|
352
|
+
*/
|
|
353
|
+
interface PerformanceNodeTiming extends PerformanceEntry {
|
|
354
|
+
/**
|
|
355
|
+
* The high resolution millisecond timestamp at which the Node.js process
|
|
356
|
+
* completed bootstrapping. If bootstrapping has not yet finished, the property
|
|
357
|
+
* has the value of -1.
|
|
358
|
+
* @since v8.5.0
|
|
359
|
+
*/
|
|
360
|
+
readonly bootstrapComplete: number;
|
|
361
|
+
readonly entryType: "node";
|
|
362
|
+
/**
|
|
363
|
+
* The high resolution millisecond timestamp at which the Node.js environment was
|
|
364
|
+
* initialized.
|
|
365
|
+
* @since v8.5.0
|
|
366
|
+
*/
|
|
367
|
+
readonly environment: number;
|
|
368
|
+
/**
|
|
369
|
+
* The high resolution millisecond timestamp of the amount of time the event loop
|
|
370
|
+
* has been idle within the event loop's event provider (e.g. `epoll_wait`). This
|
|
371
|
+
* does not take CPU usage into consideration. If the event loop has not yet
|
|
372
|
+
* started (e.g., in the first tick of the main script), the property has the
|
|
373
|
+
* value of 0.
|
|
374
|
+
* @since v14.10.0, v12.19.0
|
|
375
|
+
*/
|
|
376
|
+
readonly idleTime: number;
|
|
377
|
+
/**
|
|
378
|
+
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
379
|
+
* exited. If the event loop has not yet exited, the property has the value of -1\.
|
|
380
|
+
* It can only have a value of not -1 in a handler of the `'exit'` event.
|
|
381
|
+
* @since v8.5.0
|
|
382
|
+
*/
|
|
383
|
+
readonly loopExit: number;
|
|
384
|
+
/**
|
|
385
|
+
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
386
|
+
* started. If the event loop has not yet started (e.g., in the first tick of the
|
|
387
|
+
* main script), the property has the value of -1.
|
|
388
|
+
* @since v8.5.0
|
|
389
|
+
*/
|
|
390
|
+
readonly loopStart: number;
|
|
391
|
+
/**
|
|
392
|
+
* The high resolution millisecond timestamp at which the Node.js process was initialized.
|
|
393
|
+
* @since v8.5.0
|
|
394
|
+
*/
|
|
395
|
+
readonly nodeStart: number;
|
|
396
|
+
/**
|
|
397
|
+
* This is a wrapper to the `uv_metrics_info` function.
|
|
398
|
+
* It returns the current set of event loop metrics.
|
|
399
|
+
*
|
|
400
|
+
* It is recommended to use this property inside a function whose execution was
|
|
401
|
+
* scheduled using `setImmediate` to avoid collecting metrics before finishing all
|
|
402
|
+
* operations scheduled during the current loop iteration.
|
|
403
|
+
* @since v22.8.0, v20.18.0
|
|
404
|
+
*/
|
|
405
|
+
readonly uvMetricsInfo: UVMetrics;
|
|
406
|
+
/**
|
|
407
|
+
* The high resolution millisecond timestamp at which the V8 platform was
|
|
408
|
+
* initialized.
|
|
409
|
+
* @since v8.5.0
|
|
410
|
+
*/
|
|
411
|
+
readonly v8Start: number;
|
|
412
|
+
}
|
|
413
|
+
namespace constants {
|
|
414
|
+
const NODE_PERFORMANCE_GC_MAJOR: number;
|
|
415
|
+
const NODE_PERFORMANCE_GC_MINOR: number;
|
|
416
|
+
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
|
417
|
+
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
|
418
|
+
const NODE_PERFORMANCE_GC_FLAGS_NO: number;
|
|
419
|
+
const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
|
|
420
|
+
const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
|
|
421
|
+
const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
|
|
422
|
+
const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
|
|
423
|
+
const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
|
|
424
|
+
const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
|
|
425
|
+
}
|
|
426
|
+
interface EventLoopMonitorOptions {
|
|
427
|
+
/**
|
|
428
|
+
* The sampling rate in milliseconds.
|
|
429
|
+
* Must be greater than zero.
|
|
430
|
+
* @default 10
|
|
431
|
+
*/
|
|
432
|
+
resolution?: number | undefined;
|
|
433
|
+
}
|
|
434
|
+
interface Histogram {
|
|
435
|
+
/**
|
|
436
|
+
* The number of samples recorded by the histogram.
|
|
437
|
+
* @since v17.4.0, v16.14.0
|
|
438
|
+
*/
|
|
439
|
+
readonly count: number;
|
|
440
|
+
/**
|
|
441
|
+
* The number of samples recorded by the histogram.
|
|
442
|
+
* v17.4.0, v16.14.0
|
|
443
|
+
*/
|
|
444
|
+
readonly countBigInt: bigint;
|
|
445
|
+
/**
|
|
446
|
+
* The number of times the event loop delay exceeded the maximum 1 hour event
|
|
447
|
+
* loop delay threshold.
|
|
448
|
+
* @since v11.10.0
|
|
449
|
+
*/
|
|
450
|
+
readonly exceeds: number;
|
|
451
|
+
/**
|
|
452
|
+
* The number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.
|
|
453
|
+
* @since v17.4.0, v16.14.0
|
|
454
|
+
*/
|
|
455
|
+
readonly exceedsBigInt: bigint;
|
|
456
|
+
/**
|
|
457
|
+
* The maximum recorded event loop delay.
|
|
458
|
+
* @since v11.10.0
|
|
459
|
+
*/
|
|
460
|
+
readonly max: number;
|
|
461
|
+
/**
|
|
462
|
+
* The maximum recorded event loop delay.
|
|
463
|
+
* v17.4.0, v16.14.0
|
|
464
|
+
*/
|
|
465
|
+
readonly maxBigInt: number;
|
|
466
|
+
/**
|
|
467
|
+
* The mean of the recorded event loop delays.
|
|
468
|
+
* @since v11.10.0
|
|
469
|
+
*/
|
|
470
|
+
readonly mean: number;
|
|
471
|
+
/**
|
|
472
|
+
* The minimum recorded event loop delay.
|
|
473
|
+
* @since v11.10.0
|
|
474
|
+
*/
|
|
475
|
+
readonly min: number;
|
|
476
|
+
/**
|
|
477
|
+
* The minimum recorded event loop delay.
|
|
478
|
+
* v17.4.0, v16.14.0
|
|
479
|
+
*/
|
|
480
|
+
readonly minBigInt: bigint;
|
|
481
|
+
/**
|
|
482
|
+
* Returns the value at the given percentile.
|
|
483
|
+
* @since v11.10.0
|
|
484
|
+
* @param percentile A percentile value in the range (0, 100].
|
|
485
|
+
*/
|
|
486
|
+
percentile(percentile: number): number;
|
|
487
|
+
/**
|
|
488
|
+
* Returns the value at the given percentile.
|
|
489
|
+
* @since v17.4.0, v16.14.0
|
|
490
|
+
* @param percentile A percentile value in the range (0, 100].
|
|
491
|
+
*/
|
|
492
|
+
percentileBigInt(percentile: number): bigint;
|
|
493
|
+
/**
|
|
494
|
+
* Returns a `Map` object detailing the accumulated percentile distribution.
|
|
495
|
+
* @since v11.10.0
|
|
496
|
+
*/
|
|
497
|
+
readonly percentiles: Map<number, number>;
|
|
498
|
+
/**
|
|
499
|
+
* Returns a `Map` object detailing the accumulated percentile distribution.
|
|
500
|
+
* @since v17.4.0, v16.14.0
|
|
501
|
+
*/
|
|
502
|
+
readonly percentilesBigInt: Map<bigint, bigint>;
|
|
503
|
+
/**
|
|
504
|
+
* Resets the collected histogram data.
|
|
505
|
+
* @since v11.10.0
|
|
506
|
+
*/
|
|
507
|
+
reset(): void;
|
|
508
|
+
/**
|
|
509
|
+
* The standard deviation of the recorded event loop delays.
|
|
510
|
+
* @since v11.10.0
|
|
511
|
+
*/
|
|
512
|
+
readonly stddev: number;
|
|
513
|
+
}
|
|
514
|
+
interface IntervalHistogram extends Histogram {
|
|
515
|
+
/**
|
|
516
|
+
* Enables the update interval timer. Returns `true` if the timer was
|
|
517
|
+
* started, `false` if it was already started.
|
|
518
|
+
* @since v11.10.0
|
|
519
|
+
*/
|
|
520
|
+
enable(): boolean;
|
|
521
|
+
/**
|
|
522
|
+
* Disables the update interval timer. Returns `true` if the timer was
|
|
523
|
+
* stopped, `false` if it was already stopped.
|
|
524
|
+
* @since v11.10.0
|
|
525
|
+
*/
|
|
526
|
+
disable(): boolean;
|
|
527
|
+
/**
|
|
528
|
+
* Disables the update interval timer when the histogram is disposed.
|
|
529
|
+
*
|
|
530
|
+
* ```js
|
|
531
|
+
* const { monitorEventLoopDelay } = require('node:perf_hooks');
|
|
532
|
+
* {
|
|
533
|
+
* using hist = monitorEventLoopDelay({ resolution: 20 });
|
|
534
|
+
* hist.enable();
|
|
535
|
+
* // The histogram will be disabled when the block is exited.
|
|
536
|
+
* }
|
|
537
|
+
* ```
|
|
538
|
+
* @since v24.2.0
|
|
539
|
+
*/
|
|
540
|
+
[Symbol.dispose](): void;
|
|
541
|
+
}
|
|
542
|
+
interface RecordableHistogram extends Histogram {
|
|
543
|
+
/**
|
|
544
|
+
* @since v15.9.0, v14.18.0
|
|
545
|
+
* @param val The amount to record in the histogram.
|
|
546
|
+
*/
|
|
547
|
+
record(val: number | bigint): void;
|
|
548
|
+
/**
|
|
549
|
+
* Calculates the amount of time (in nanoseconds) that has passed since the
|
|
550
|
+
* previous call to `recordDelta()` and records that amount in the histogram.
|
|
551
|
+
* @since v15.9.0, v14.18.0
|
|
552
|
+
*/
|
|
553
|
+
recordDelta(): void;
|
|
554
|
+
/**
|
|
555
|
+
* Adds the values from `other` to this histogram.
|
|
556
|
+
* @since v17.4.0, v16.14.0
|
|
557
|
+
*/
|
|
558
|
+
add(other: RecordableHistogram): void;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
562
|
+
*
|
|
563
|
+
* Creates an `IntervalHistogram` object that samples and reports the event loop
|
|
564
|
+
* delay over time. The delays will be reported in nanoseconds.
|
|
565
|
+
*
|
|
566
|
+
* Using a timer to detect approximate event loop delay works because the
|
|
567
|
+
* execution of timers is tied specifically to the lifecycle of the libuv
|
|
568
|
+
* event loop. That is, a delay in the loop will cause a delay in the execution
|
|
569
|
+
* of the timer, and those delays are specifically what this API is intended to
|
|
570
|
+
* detect.
|
|
571
|
+
*
|
|
572
|
+
* ```js
|
|
573
|
+
* import { monitorEventLoopDelay } from 'node:perf_hooks';
|
|
574
|
+
* const h = monitorEventLoopDelay({ resolution: 20 });
|
|
575
|
+
* h.enable();
|
|
576
|
+
* // Do something.
|
|
577
|
+
* h.disable();
|
|
578
|
+
* console.log(h.min);
|
|
579
|
+
* console.log(h.max);
|
|
580
|
+
* console.log(h.mean);
|
|
581
|
+
* console.log(h.stddev);
|
|
582
|
+
* console.log(h.percentiles);
|
|
583
|
+
* console.log(h.percentile(50));
|
|
584
|
+
* console.log(h.percentile(99));
|
|
585
|
+
* ```
|
|
586
|
+
* @since v11.10.0
|
|
587
|
+
*/
|
|
588
|
+
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
|
|
589
|
+
interface CreateHistogramOptions {
|
|
590
|
+
/**
|
|
591
|
+
* The minimum recordable value. Must be an integer value greater than 0.
|
|
592
|
+
* @default 1
|
|
593
|
+
*/
|
|
594
|
+
lowest?: number | bigint | undefined;
|
|
595
|
+
/**
|
|
596
|
+
* The maximum recordable value. Must be an integer value greater than min.
|
|
597
|
+
* @default Number.MAX_SAFE_INTEGER
|
|
598
|
+
*/
|
|
599
|
+
highest?: number | bigint | undefined;
|
|
600
|
+
/**
|
|
601
|
+
* The number of accuracy digits. Must be a number between 1 and 5.
|
|
602
|
+
* @default 3
|
|
603
|
+
*/
|
|
604
|
+
figures?: number | undefined;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Returns a `RecordableHistogram`.
|
|
608
|
+
* @since v15.9.0, v14.18.0
|
|
609
|
+
*/
|
|
610
|
+
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
|
611
|
+
// TODO: remove these in a future major
|
|
612
|
+
/** @deprecated Use the canonical `PerformanceMarkOptions` instead. */
|
|
613
|
+
interface MarkOptions extends PerformanceMarkOptions {}
|
|
614
|
+
/** @deprecated Use the canonical `PerformanceMeasureOptions` instead. */
|
|
615
|
+
interface MeasureOptions extends PerformanceMeasureOptions {}
|
|
616
|
+
/** @deprecated Use `PerformanceTimerifyOptions` instead. */
|
|
617
|
+
interface TimerifyOptions extends PerformanceTimerifyOptions {}
|
|
618
|
+
}
|
|
619
|
+
declare module "perf_hooks" {
|
|
620
|
+
export * from "node:perf_hooks";
|
|
621
|
+
}
|