@types/node 16.4.2 → 16.4.6
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/README.md +2 -2
- node/assert/strict.d.ts +0 -1
- node/assert.d.ts +1352 -40
- node/async_hooks.d.ts +359 -90
- node/buffer.d.ts +1503 -78
- node/child_process.d.ts +1054 -233
- node/cluster.d.ts +320 -100
- node/console.d.ts +305 -32
- node/crypto.d.ts +3115 -739
- node/dgram.d.ts +446 -55
- node/diagnostics_channel.d.ts +85 -12
- node/dns/promises.d.ts +292 -36
- node/dns.d.ts +410 -97
- node/domain.d.ts +154 -10
- node/events.d.ts +377 -31
- node/fs/promises.d.ts +697 -273
- node/fs.d.ts +2257 -858
- node/http.d.ts +888 -80
- node/http2.d.ts +1525 -459
- node/https.d.ts +261 -11
- node/index.d.ts +25 -0
- node/inspector.d.ts +354 -661
- node/module.d.ts +49 -11
- node/net.d.ts +548 -140
- node/os.d.ts +236 -26
- node/package.json +7 -2
- node/path.d.ts +9 -5
- node/perf_hooks.d.ts +288 -90
- node/process.d.ts +1092 -153
- node/punycode.d.ts +65 -26
- node/querystring.d.ts +107 -8
- node/readline.d.ts +425 -79
- node/repl.d.ts +135 -110
- node/stream/promises.d.ts +15 -44
- node/stream.d.ts +927 -225
- node/string_decoder.d.ts +57 -1
- node/timers/promises.d.ts +97 -9
- node/timers.d.ts +29 -10
- node/tls.d.ts +444 -221
- node/trace_events.d.ts +107 -11
- node/tty.d.ts +163 -23
- node/url.d.ts +739 -29
- node/util.d.ts +1361 -73
- node/v8.d.ts +254 -78
- node/vm.d.ts +381 -33
- node/wasi.d.ts +107 -24
- node/worker_threads.d.ts +494 -131
- node/zlib.d.ts +215 -63
node/perf_hooks.d.ts
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
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
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* const { PerformanceObserver, performance } = require('perf_hooks');
|
|
13
|
+
*
|
|
14
|
+
* const obs = new PerformanceObserver((items) => {
|
|
15
|
+
* console.log(items.getEntries()[0].duration);
|
|
16
|
+
* performance.clearMarks();
|
|
17
|
+
* });
|
|
18
|
+
* obs.observe({ type: 'measure' });
|
|
19
|
+
* performance.measure('Start to Now');
|
|
20
|
+
*
|
|
21
|
+
* performance.mark('A');
|
|
22
|
+
* doSomeLongRunningProcess(() => {
|
|
23
|
+
* performance.measure('A to Now', 'A');
|
|
24
|
+
*
|
|
25
|
+
* performance.mark('B');
|
|
26
|
+
* performance.measure('A to B', 'A', 'B');
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/perf_hooks.js)
|
|
30
|
+
*/
|
|
1
31
|
declare module 'perf_hooks' {
|
|
2
32
|
import { AsyncResource } from 'node:async_hooks';
|
|
3
|
-
|
|
4
33
|
type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
|
|
5
|
-
|
|
6
34
|
interface NodeGCPerformanceDetail {
|
|
7
35
|
/**
|
|
8
36
|
* When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
|
|
@@ -10,7 +38,6 @@ declare module 'perf_hooks' {
|
|
|
10
38
|
* See perf_hooks.constants for valid values.
|
|
11
39
|
*/
|
|
12
40
|
readonly kind?: number | undefined;
|
|
13
|
-
|
|
14
41
|
/**
|
|
15
42
|
* When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
|
|
16
43
|
* property contains additional information about garbage collection operation.
|
|
@@ -18,86 +45,108 @@ declare module 'perf_hooks' {
|
|
|
18
45
|
*/
|
|
19
46
|
readonly flags?: number | undefined;
|
|
20
47
|
}
|
|
21
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @since v8.5.0
|
|
50
|
+
*/
|
|
22
51
|
class PerformanceEntry {
|
|
23
52
|
protected constructor();
|
|
24
53
|
/**
|
|
25
|
-
* The total number of milliseconds elapsed for this entry.
|
|
26
|
-
*
|
|
54
|
+
* The total number of milliseconds elapsed for this entry. This value will not
|
|
55
|
+
* be meaningful for all Performance Entry types.
|
|
56
|
+
* @since v8.5.0
|
|
27
57
|
*/
|
|
28
58
|
readonly duration: number;
|
|
29
|
-
|
|
30
59
|
/**
|
|
31
60
|
* The name of the performance entry.
|
|
61
|
+
* @since v8.5.0
|
|
32
62
|
*/
|
|
33
63
|
readonly name: string;
|
|
34
|
-
|
|
35
64
|
/**
|
|
36
|
-
* The high resolution millisecond timestamp marking the starting time of the
|
|
65
|
+
* The high resolution millisecond timestamp marking the starting time of the
|
|
66
|
+
* Performance Entry.
|
|
67
|
+
* @since v8.5.0
|
|
37
68
|
*/
|
|
38
69
|
readonly startTime: number;
|
|
39
|
-
|
|
40
70
|
/**
|
|
41
|
-
* The type of the performance entry.
|
|
42
|
-
*
|
|
71
|
+
* The type of the performance entry. It may be one of:
|
|
72
|
+
*
|
|
73
|
+
* * `'node'` (Node.js only)
|
|
74
|
+
* * `'mark'` (available on the Web)
|
|
75
|
+
* * `'measure'` (available on the Web)
|
|
76
|
+
* * `'gc'` (Node.js only)
|
|
77
|
+
* * `'function'` (Node.js only)
|
|
78
|
+
* * `'http2'` (Node.js only)
|
|
79
|
+
* * `'http'` (Node.js only)
|
|
80
|
+
* @since v8.5.0
|
|
43
81
|
*/
|
|
44
82
|
readonly entryType: EntryType;
|
|
45
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Additional detail specific to the `entryType`.
|
|
85
|
+
* @since v16.0.0
|
|
86
|
+
*/
|
|
46
87
|
readonly details?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
|
|
47
88
|
}
|
|
48
|
-
|
|
89
|
+
/**
|
|
90
|
+
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
91
|
+
*
|
|
92
|
+
* Provides timing details for Node.js itself. The constructor of this class
|
|
93
|
+
* is not exposed to users.
|
|
94
|
+
* @since v8.5.0
|
|
95
|
+
*/
|
|
49
96
|
class PerformanceNodeTiming extends PerformanceEntry {
|
|
50
97
|
/**
|
|
51
|
-
* The high resolution millisecond timestamp at which the Node.js process
|
|
98
|
+
* The high resolution millisecond timestamp at which the Node.js process
|
|
99
|
+
* completed bootstrapping. If bootstrapping has not yet finished, the property
|
|
100
|
+
* has the value of -1.
|
|
101
|
+
* @since v8.5.0
|
|
52
102
|
*/
|
|
53
103
|
readonly bootstrapComplete: number;
|
|
54
|
-
|
|
55
104
|
/**
|
|
56
|
-
* The high resolution millisecond timestamp at which the Node.js
|
|
57
|
-
*
|
|
105
|
+
* The high resolution millisecond timestamp at which the Node.js environment was
|
|
106
|
+
* initialized.
|
|
107
|
+
* @since v8.5.0
|
|
58
108
|
*/
|
|
59
109
|
readonly environment: number;
|
|
60
|
-
|
|
61
110
|
/**
|
|
62
|
-
* The high resolution millisecond timestamp
|
|
111
|
+
* The high resolution millisecond timestamp of the amount of time the event loop
|
|
112
|
+
* has been idle within the event loop's event provider (e.g. `epoll_wait`). This
|
|
113
|
+
* does not take CPU usage into consideration. If the event loop has not yet
|
|
114
|
+
* started (e.g., in the first tick of the main script), the property has the
|
|
115
|
+
* value of 0.
|
|
116
|
+
* @since v14.10.0, v12.19.0
|
|
63
117
|
*/
|
|
64
118
|
readonly idleTime: number;
|
|
65
|
-
|
|
66
119
|
/**
|
|
67
|
-
* The high resolution millisecond timestamp
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
120
|
+
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
121
|
+
* exited. If the event loop has not yet exited, the property has the value of -1\.
|
|
122
|
+
* It can only have a value of not -1 in a handler of the `'exit'` event.
|
|
123
|
+
* @since v8.5.0
|
|
71
124
|
*/
|
|
72
125
|
readonly loopExit: number;
|
|
73
|
-
|
|
74
126
|
/**
|
|
75
|
-
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
76
|
-
* If the event loop has not yet started (e.g., in the first tick of the
|
|
127
|
+
* The high resolution millisecond timestamp at which the Node.js event loop
|
|
128
|
+
* started. If the event loop has not yet started (e.g., in the first tick of the
|
|
129
|
+
* main script), the property has the value of -1.
|
|
130
|
+
* @since v8.5.0
|
|
77
131
|
*/
|
|
78
132
|
readonly loopStart: number;
|
|
79
|
-
|
|
80
133
|
/**
|
|
81
|
-
* The high resolution millisecond timestamp at which the V8 platform was
|
|
134
|
+
* The high resolution millisecond timestamp at which the V8 platform was
|
|
135
|
+
* initialized.
|
|
136
|
+
* @since v8.5.0
|
|
82
137
|
*/
|
|
83
138
|
readonly v8Start: number;
|
|
84
139
|
}
|
|
85
|
-
|
|
86
140
|
interface EventLoopUtilization {
|
|
87
141
|
idle: number;
|
|
88
142
|
active: number;
|
|
89
143
|
utilization: number;
|
|
90
144
|
}
|
|
91
|
-
|
|
92
145
|
/**
|
|
93
146
|
* @param util1 The result of a previous call to eventLoopUtilization()
|
|
94
147
|
* @param util2 The result of a previous call to eventLoopUtilization() prior to util1
|
|
95
148
|
*/
|
|
96
|
-
type EventLoopUtilityFunction = (
|
|
97
|
-
util1?: EventLoopUtilization,
|
|
98
|
-
util2?: EventLoopUtilization,
|
|
99
|
-
) => EventLoopUtilization;
|
|
100
|
-
|
|
149
|
+
type EventLoopUtilityFunction = (util1?: EventLoopUtilization, util2?: EventLoopUtilization) => EventLoopUtilization;
|
|
101
150
|
interface MarkOptions {
|
|
102
151
|
/**
|
|
103
152
|
* Additional optional detail to include with the mark.
|
|
@@ -109,7 +158,6 @@ declare module 'perf_hooks' {
|
|
|
109
158
|
*/
|
|
110
159
|
startTime?: number | undefined;
|
|
111
160
|
}
|
|
112
|
-
|
|
113
161
|
interface MeasureOptions {
|
|
114
162
|
/**
|
|
115
163
|
* Additional optional detail to include with the mark.
|
|
@@ -128,7 +176,6 @@ declare module 'perf_hooks' {
|
|
|
128
176
|
*/
|
|
129
177
|
start?: number | string | undefined;
|
|
130
178
|
}
|
|
131
|
-
|
|
132
179
|
interface TimerifyOptions {
|
|
133
180
|
/**
|
|
134
181
|
* A histogram object created using
|
|
@@ -137,7 +184,6 @@ declare module 'perf_hooks' {
|
|
|
137
184
|
*/
|
|
138
185
|
histogram?: RecordableHistogram | undefined;
|
|
139
186
|
}
|
|
140
|
-
|
|
141
187
|
interface Performance {
|
|
142
188
|
/**
|
|
143
189
|
* If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
|
|
@@ -145,7 +191,6 @@ declare module 'perf_hooks' {
|
|
|
145
191
|
* @param name
|
|
146
192
|
*/
|
|
147
193
|
clearMarks(name?: string): void;
|
|
148
|
-
|
|
149
194
|
/**
|
|
150
195
|
* Creates a new PerformanceMark entry in the Performance Timeline.
|
|
151
196
|
* A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
|
|
@@ -154,7 +199,6 @@ declare module 'perf_hooks' {
|
|
|
154
199
|
* @param name
|
|
155
200
|
*/
|
|
156
201
|
mark(name?: string, options?: MarkOptions): void;
|
|
157
|
-
|
|
158
202
|
/**
|
|
159
203
|
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
|
160
204
|
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
|
@@ -172,29 +216,24 @@ declare module 'perf_hooks' {
|
|
|
172
216
|
*/
|
|
173
217
|
measure(name: string, startMark?: string, endMark?: string): void;
|
|
174
218
|
measure(name: string, options: MeasureOptions): void;
|
|
175
|
-
|
|
176
219
|
/**
|
|
177
220
|
* An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
|
|
178
221
|
*/
|
|
179
222
|
readonly nodeTiming: PerformanceNodeTiming;
|
|
180
|
-
|
|
181
223
|
/**
|
|
182
224
|
* @return the current high resolution millisecond timestamp
|
|
183
225
|
*/
|
|
184
226
|
now(): number;
|
|
185
|
-
|
|
186
227
|
/**
|
|
187
228
|
* The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
|
|
188
229
|
*/
|
|
189
230
|
readonly timeOrigin: number;
|
|
190
|
-
|
|
191
231
|
/**
|
|
192
232
|
* Wraps a function within a new function that measures the running time of the wrapped function.
|
|
193
233
|
* A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
|
|
194
234
|
* @param fn
|
|
195
235
|
*/
|
|
196
236
|
timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
|
|
197
|
-
|
|
198
237
|
/**
|
|
199
238
|
* eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time.
|
|
200
239
|
* It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait).
|
|
@@ -202,49 +241,173 @@ declare module 'perf_hooks' {
|
|
|
202
241
|
*/
|
|
203
242
|
eventLoopUtilization: EventLoopUtilityFunction;
|
|
204
243
|
}
|
|
205
|
-
|
|
206
244
|
interface PerformanceObserverEntryList {
|
|
207
245
|
/**
|
|
208
|
-
*
|
|
246
|
+
* Returns a list of `PerformanceEntry` objects in chronological order
|
|
247
|
+
* with respect to `performanceEntry.startTime`.
|
|
248
|
+
*
|
|
249
|
+
* ```js
|
|
250
|
+
* const {
|
|
251
|
+
* performance,
|
|
252
|
+
* PerformanceObserver
|
|
253
|
+
* } = require('perf_hooks');
|
|
254
|
+
*
|
|
255
|
+
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
256
|
+
* console.log(perfObserverList.getEntries());
|
|
257
|
+
*
|
|
258
|
+
* * [
|
|
259
|
+
* * PerformanceEntry {
|
|
260
|
+
* * name: 'test',
|
|
261
|
+
* * entryType: 'mark',
|
|
262
|
+
* * startTime: 81.465639,
|
|
263
|
+
* * duration: 0
|
|
264
|
+
* * },
|
|
265
|
+
* * PerformanceEntry {
|
|
266
|
+
* * name: 'meow',
|
|
267
|
+
* * entryType: 'mark',
|
|
268
|
+
* * startTime: 81.860064,
|
|
269
|
+
* * duration: 0
|
|
270
|
+
* * }
|
|
271
|
+
* * ]
|
|
272
|
+
*
|
|
273
|
+
* observer.disconnect();
|
|
274
|
+
* });
|
|
275
|
+
* obs.observe({ type: 'mark' });
|
|
276
|
+
*
|
|
277
|
+
* performance.mark('test');
|
|
278
|
+
* performance.mark('meow');
|
|
279
|
+
* ```
|
|
280
|
+
* @since v8.5.0
|
|
209
281
|
*/
|
|
210
282
|
getEntries(): PerformanceEntry[];
|
|
211
|
-
|
|
212
283
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
284
|
+
* Returns a list of `PerformanceEntry` objects in chronological order
|
|
285
|
+
* with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
|
|
286
|
+
* equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
|
|
287
|
+
*
|
|
288
|
+
* ```js
|
|
289
|
+
* const {
|
|
290
|
+
* performance,
|
|
291
|
+
* PerformanceObserver
|
|
292
|
+
* } = require('perf_hooks');
|
|
293
|
+
*
|
|
294
|
+
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
295
|
+
* console.log(perfObserverList.getEntriesByName('meow'));
|
|
296
|
+
*
|
|
297
|
+
* * [
|
|
298
|
+
* * PerformanceEntry {
|
|
299
|
+
* * name: 'meow',
|
|
300
|
+
* * entryType: 'mark',
|
|
301
|
+
* * startTime: 98.545991,
|
|
302
|
+
* * duration: 0
|
|
303
|
+
* * }
|
|
304
|
+
* * ]
|
|
305
|
+
*
|
|
306
|
+
* console.log(perfObserverList.getEntriesByName('nope')); // []
|
|
307
|
+
*
|
|
308
|
+
* console.log(perfObserverList.getEntriesByName('test', 'mark'));
|
|
309
|
+
*
|
|
310
|
+
* * [
|
|
311
|
+
* * PerformanceEntry {
|
|
312
|
+
* * name: 'test',
|
|
313
|
+
* * entryType: 'mark',
|
|
314
|
+
* * startTime: 63.518931,
|
|
315
|
+
* * duration: 0
|
|
316
|
+
* * }
|
|
317
|
+
* * ]
|
|
318
|
+
*
|
|
319
|
+
* console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
|
|
320
|
+
* observer.disconnect();
|
|
321
|
+
* });
|
|
322
|
+
* obs.observe({ entryTypes: ['mark', 'measure'] });
|
|
323
|
+
*
|
|
324
|
+
* performance.mark('test');
|
|
325
|
+
* performance.mark('meow');
|
|
326
|
+
* ```
|
|
327
|
+
* @since v8.5.0
|
|
215
328
|
*/
|
|
216
329
|
getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
|
|
217
|
-
|
|
218
330
|
/**
|
|
219
|
-
*
|
|
220
|
-
* whose performanceEntry.entryType
|
|
331
|
+
* Returns a list of `PerformanceEntry` objects in chronological order
|
|
332
|
+
* with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`.
|
|
333
|
+
*
|
|
334
|
+
* ```js
|
|
335
|
+
* const {
|
|
336
|
+
* performance,
|
|
337
|
+
* PerformanceObserver
|
|
338
|
+
* } = require('perf_hooks');
|
|
339
|
+
*
|
|
340
|
+
* const obs = new PerformanceObserver((perfObserverList, observer) => {
|
|
341
|
+
* console.log(perfObserverList.getEntriesByType('mark'));
|
|
342
|
+
*
|
|
343
|
+
* * [
|
|
344
|
+
* * PerformanceEntry {
|
|
345
|
+
* * name: 'test',
|
|
346
|
+
* * entryType: 'mark',
|
|
347
|
+
* * startTime: 55.897834,
|
|
348
|
+
* * duration: 0
|
|
349
|
+
* * },
|
|
350
|
+
* * PerformanceEntry {
|
|
351
|
+
* * name: 'meow',
|
|
352
|
+
* * entryType: 'mark',
|
|
353
|
+
* * startTime: 56.350146,
|
|
354
|
+
* * duration: 0
|
|
355
|
+
* * }
|
|
356
|
+
* * ]
|
|
357
|
+
*
|
|
358
|
+
* observer.disconnect();
|
|
359
|
+
* });
|
|
360
|
+
* obs.observe({ type: 'mark' });
|
|
361
|
+
*
|
|
362
|
+
* performance.mark('test');
|
|
363
|
+
* performance.mark('meow');
|
|
364
|
+
* ```
|
|
365
|
+
* @since v8.5.0
|
|
221
366
|
*/
|
|
222
367
|
getEntriesByType(type: EntryType): PerformanceEntry[];
|
|
223
368
|
}
|
|
224
|
-
|
|
225
369
|
type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
|
|
226
|
-
|
|
227
370
|
class PerformanceObserver extends AsyncResource {
|
|
228
371
|
constructor(callback: PerformanceObserverCallback);
|
|
229
|
-
|
|
230
372
|
/**
|
|
231
|
-
* Disconnects the PerformanceObserver instance from all notifications.
|
|
373
|
+
* Disconnects the `PerformanceObserver` instance from all notifications.
|
|
374
|
+
* @since v8.5.0
|
|
232
375
|
*/
|
|
233
376
|
disconnect(): void;
|
|
234
|
-
|
|
235
377
|
/**
|
|
236
|
-
* Subscribes the PerformanceObserver instance to notifications of new PerformanceEntry instances identified by options.entryTypes
|
|
237
|
-
*
|
|
238
|
-
|
|
239
|
-
|
|
378
|
+
* Subscribes the `<PerformanceObserver>` instance to notifications of new `<PerformanceEntry>` instances identified either by `options.entryTypes`or `options.type`:
|
|
379
|
+
*
|
|
380
|
+
* ```js
|
|
381
|
+
* const {
|
|
382
|
+
* performance,
|
|
383
|
+
* PerformanceObserver
|
|
384
|
+
* } = require('perf_hooks');
|
|
385
|
+
*
|
|
386
|
+
* const obs = new PerformanceObserver((list, observer) => {
|
|
387
|
+
* // Called three times synchronously. `list` contains one item.
|
|
388
|
+
* });
|
|
389
|
+
* obs.observe({ type: 'mark' });
|
|
390
|
+
*
|
|
391
|
+
* for (let n = 0; n < 3; n++)
|
|
392
|
+
* performance.mark(`test${n}`);
|
|
393
|
+
* ```
|
|
394
|
+
* @since v8.5.0
|
|
395
|
+
*/
|
|
396
|
+
observe(
|
|
397
|
+
options:
|
|
398
|
+
| {
|
|
399
|
+
entryTypes: ReadonlyArray<EntryType>;
|
|
400
|
+
}
|
|
401
|
+
| {
|
|
402
|
+
type: EntryType;
|
|
403
|
+
}
|
|
404
|
+
): void;
|
|
240
405
|
}
|
|
241
|
-
|
|
242
406
|
namespace constants {
|
|
243
407
|
const NODE_PERFORMANCE_GC_MAJOR: number;
|
|
244
408
|
const NODE_PERFORMANCE_GC_MINOR: number;
|
|
245
409
|
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
|
|
246
410
|
const NODE_PERFORMANCE_GC_WEAKCB: number;
|
|
247
|
-
|
|
248
411
|
const NODE_PERFORMANCE_GC_FLAGS_NO: number;
|
|
249
412
|
const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
|
|
250
413
|
const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
|
|
@@ -253,9 +416,7 @@ declare module 'perf_hooks' {
|
|
|
253
416
|
const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
|
|
254
417
|
const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
|
|
255
418
|
}
|
|
256
|
-
|
|
257
419
|
const performance: Performance;
|
|
258
|
-
|
|
259
420
|
interface EventLoopMonitorOptions {
|
|
260
421
|
/**
|
|
261
422
|
* The sampling rate in milliseconds.
|
|
@@ -264,79 +425,114 @@ declare module 'perf_hooks' {
|
|
|
264
425
|
*/
|
|
265
426
|
resolution?: number | undefined;
|
|
266
427
|
}
|
|
267
|
-
|
|
268
428
|
interface Histogram {
|
|
269
429
|
/**
|
|
270
|
-
*
|
|
430
|
+
* Returns a `Map` object detailing the accumulated percentile distribution.
|
|
431
|
+
* @since v11.10.0
|
|
271
432
|
*/
|
|
272
433
|
readonly percentiles: Map<number, number>;
|
|
273
|
-
|
|
274
434
|
/**
|
|
275
|
-
* The number of times the event loop delay exceeded the maximum 1 hour
|
|
435
|
+
* The number of times the event loop delay exceeded the maximum 1 hour event
|
|
436
|
+
* loop delay threshold.
|
|
437
|
+
* @since v11.10.0
|
|
276
438
|
*/
|
|
277
439
|
readonly exceeds: number;
|
|
278
|
-
|
|
279
440
|
/**
|
|
280
441
|
* The minimum recorded event loop delay.
|
|
442
|
+
* @since v11.10.0
|
|
281
443
|
*/
|
|
282
444
|
readonly min: number;
|
|
283
|
-
|
|
284
445
|
/**
|
|
285
446
|
* The maximum recorded event loop delay.
|
|
447
|
+
* @since v11.10.0
|
|
286
448
|
*/
|
|
287
449
|
readonly max: number;
|
|
288
|
-
|
|
289
450
|
/**
|
|
290
451
|
* The mean of the recorded event loop delays.
|
|
452
|
+
* @since v11.10.0
|
|
291
453
|
*/
|
|
292
454
|
readonly mean: number;
|
|
293
|
-
|
|
294
455
|
/**
|
|
295
456
|
* The standard deviation of the recorded event loop delays.
|
|
457
|
+
* @since v11.10.0
|
|
296
458
|
*/
|
|
297
459
|
readonly stddev: number;
|
|
298
|
-
|
|
299
460
|
/**
|
|
300
461
|
* Resets the collected histogram data.
|
|
462
|
+
* @since v11.10.0
|
|
301
463
|
*/
|
|
302
464
|
reset(): void;
|
|
303
|
-
|
|
304
465
|
/**
|
|
305
466
|
* Returns the value at the given percentile.
|
|
306
|
-
* @
|
|
467
|
+
* @since v11.10.0
|
|
468
|
+
* @param percentile A percentile value in the range (0, 100].
|
|
307
469
|
*/
|
|
308
470
|
percentile(percentile: number): number;
|
|
309
471
|
}
|
|
310
|
-
|
|
311
472
|
interface IntervalHistogram extends Histogram {
|
|
312
473
|
/**
|
|
313
|
-
* Enables the
|
|
474
|
+
* Enables the update interval timer. Returns `true` if the timer was
|
|
475
|
+
* started, `false` if it was already started.
|
|
476
|
+
* @since v11.10.0
|
|
314
477
|
*/
|
|
315
478
|
enable(): boolean;
|
|
316
479
|
/**
|
|
317
|
-
* Disables the
|
|
480
|
+
* Disables the update interval timer. Returns `true` if the timer was
|
|
481
|
+
* stopped, `false` if it was already stopped.
|
|
482
|
+
* @since v11.10.0
|
|
318
483
|
*/
|
|
319
484
|
disable(): boolean;
|
|
320
485
|
}
|
|
321
|
-
|
|
322
486
|
interface RecordableHistogram extends Histogram {
|
|
487
|
+
/**
|
|
488
|
+
* @since v15.9.0
|
|
489
|
+
* @param val The amount to record in the histogram.
|
|
490
|
+
*/
|
|
323
491
|
record(val: number | bigint): void;
|
|
324
|
-
|
|
325
492
|
/**
|
|
326
|
-
* Calculates the amount of time (in nanoseconds) that has passed since the
|
|
493
|
+
* Calculates the amount of time (in nanoseconds) that has passed since the
|
|
494
|
+
* previous call to `recordDelta()` and records that amount in the histogram.
|
|
495
|
+
*
|
|
496
|
+
* ## Examples
|
|
497
|
+
* @since v15.9.0
|
|
327
498
|
*/
|
|
328
499
|
recordDelta(): void;
|
|
329
500
|
}
|
|
330
|
-
|
|
501
|
+
/**
|
|
502
|
+
* _This property is an extension by Node.js. It is not available in Web browsers._
|
|
503
|
+
*
|
|
504
|
+
* Creates an `IntervalHistogram` object that samples and reports the event loop
|
|
505
|
+
* delay over time. The delays will be reported in nanoseconds.
|
|
506
|
+
*
|
|
507
|
+
* Using a timer to detect approximate event loop delay works because the
|
|
508
|
+
* execution of timers is tied specifically to the lifecycle of the libuv
|
|
509
|
+
* event loop. That is, a delay in the loop will cause a delay in the execution
|
|
510
|
+
* of the timer, and those delays are specifically what this API is intended to
|
|
511
|
+
* detect.
|
|
512
|
+
*
|
|
513
|
+
* ```js
|
|
514
|
+
* const { monitorEventLoopDelay } = require('perf_hooks');
|
|
515
|
+
* const h = monitorEventLoopDelay({ resolution: 20 });
|
|
516
|
+
* h.enable();
|
|
517
|
+
* // Do something.
|
|
518
|
+
* h.disable();
|
|
519
|
+
* console.log(h.min);
|
|
520
|
+
* console.log(h.max);
|
|
521
|
+
* console.log(h.mean);
|
|
522
|
+
* console.log(h.stddev);
|
|
523
|
+
* console.log(h.percentiles);
|
|
524
|
+
* console.log(h.percentile(50));
|
|
525
|
+
* console.log(h.percentile(99));
|
|
526
|
+
* ```
|
|
527
|
+
* @since v11.10.0
|
|
528
|
+
*/
|
|
331
529
|
function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
|
|
332
|
-
|
|
333
530
|
interface CreateHistogramOptions {
|
|
334
531
|
/**
|
|
335
532
|
* The minimum recordable value. Must be an integer value greater than 0.
|
|
336
533
|
* @default 1
|
|
337
534
|
*/
|
|
338
535
|
min?: number | bigint | undefined;
|
|
339
|
-
|
|
340
536
|
/**
|
|
341
537
|
* The maximum recordable value. Must be an integer value greater than min.
|
|
342
538
|
* @default Number.MAX_SAFE_INTEGER
|
|
@@ -348,10 +544,12 @@ declare module 'perf_hooks' {
|
|
|
348
544
|
*/
|
|
349
545
|
figures?: number | undefined;
|
|
350
546
|
}
|
|
351
|
-
|
|
547
|
+
/**
|
|
548
|
+
* Returns a `<RecordableHistogram>`.
|
|
549
|
+
* @since v15.9.0
|
|
550
|
+
*/
|
|
352
551
|
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
|
353
552
|
}
|
|
354
|
-
|
|
355
553
|
declare module 'node:perf_hooks' {
|
|
356
554
|
export * from 'perf_hooks';
|
|
357
555
|
}
|