Skip to content

Commit f08a282

Browse files
LiviaMedeirostargos
authored andcommitted
perf_hooks: use kEmptyObject
PR-URL: #43159 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent ca4157e commit f08a282

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

lib/internal/perf/event_loop_delay.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const {
2727
kMap,
2828
} = require('internal/histogram');
2929

30+
const {
31+
kEmptyObject,
32+
} = require('internal/util');
33+
3034
const {
3135
makeTransferable,
3236
} = require('internal/worker/js_transferable');
@@ -69,7 +73,7 @@ class ELDHistogram extends Histogram {
6973
* }} [options]
7074
* @returns {ELDHistogram}
7175
*/
72-
function monitorEventLoopDelay(options = {}) {
76+
function monitorEventLoopDelay(options = kEmptyObject) {
7377
validateObject(options, 'options');
7478

7579
const { resolution = 10 } = options;

lib/internal/perf/observe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const {
5555
customInspectSymbol: kInspect,
5656
deprecate,
5757
lazyDOMException,
58+
kEmptyObject,
5859
} = require('internal/util');
5960

6061
const {
@@ -215,7 +216,7 @@ class PerformanceObserver {
215216
this[kCallback] = callback;
216217
}
217218

218-
observe(options = {}) {
219+
observe(options = kEmptyObject) {
219220
validateObject(options, 'options');
220221
const {
221222
entryTypes,

lib/internal/perf/timerify.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ const {
3030
enqueue,
3131
} = require('internal/perf/observe');
3232

33+
const {
34+
kEmptyObject,
35+
} = require('internal/util');
36+
3337
function processComplete(name, start, args, histogram) {
3438
const duration = now() - start;
3539
if (histogram !== undefined)
@@ -48,7 +52,7 @@ function processComplete(name, start, args, histogram) {
4852
enqueue(entry);
4953
}
5054

51-
function timerify(fn, options = {}) {
55+
function timerify(fn, options = kEmptyObject) {
5256
validateFunction(fn, 'fn');
5357

5458
validateObject(options, 'options');

lib/internal/perf/usertiming.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ const {
2626
},
2727
} = require('internal/errors');
2828

29-
const { structuredClone, lazyDOMException } = require('internal/util');
29+
const {
30+
kEmptyObject,
31+
lazyDOMException,
32+
structuredClone,
33+
} = require('internal/util');
3034

3135
const markTimings = new SafeMap();
3236

@@ -60,7 +64,7 @@ class PerformanceMark extends InternalPerformanceEntry {
6064
name = `${name}`;
6165
if (nodeTimingReadOnlyAttributes.has(name))
6266
throw new ERR_INVALID_ARG_VALUE('name', name);
63-
options ??= {};
67+
options ??= kEmptyObject;
6468
validateObject(options, 'options');
6569
const startTime = options.startTime ?? now();
6670
validateNumber(startTime, 'startTime');
@@ -90,7 +94,7 @@ class PerformanceMeasure extends InternalPerformanceEntry {
9094
}
9195
}
9296

93-
function mark(name, options = {}) {
97+
function mark(name, options = kEmptyObject) {
9498
const mark = new PerformanceMark(name, options);
9599
enqueue(mark);
96100
return mark;

0 commit comments

Comments
 (0)