Skip to content

Commit a3310d1

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

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

lib/internal/perf/event_loop_delay.js

+5-1
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

+2-1
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 {
@@ -212,7 +213,7 @@ class PerformanceObserver {
212213
this.#callback = callback;
213214
}
214215

215-
observe(options = {}) {
216+
observe(options = kEmptyObject) {
216217
validateObject(options, 'options');
217218
const {
218219
entryTypes,

lib/internal/perf/timerify.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const {
3434
enqueue,
3535
} = require('internal/perf/observe');
3636

37+
const {
38+
kEmptyObject,
39+
} = require('internal/util');
40+
3741
function processComplete(name, start, args, histogram) {
3842
const duration = now() - start;
3943
if (histogram !== undefined)
@@ -52,7 +56,7 @@ function processComplete(name, start, args, histogram) {
5256
enqueue(entry);
5357
}
5458

55-
function timerify(fn, options = {}) {
59+
function timerify(fn, options = kEmptyObject) {
5660
validateFunction(fn, 'fn');
5761

5862
validateObject(options, 'options');

lib/internal/perf/usertiming.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const {
2727
} = require('internal/errors');
2828

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

3235
const markTimings = new SafeMap();
3336

@@ -61,7 +64,7 @@ class PerformanceMark extends InternalPerformanceEntry {
6164
name = `${name}`;
6265
if (nodeTimingReadOnlyAttributes.has(name))
6366
throw new ERR_INVALID_ARG_VALUE('name', name);
64-
options ??= {};
67+
options ??= kEmptyObject;
6568
validateObject(options, 'options');
6669
const startTime = options.startTime ?? now();
6770
validateNumber(startTime, 'startTime');
@@ -91,7 +94,7 @@ class PerformanceMeasure extends InternalPerformanceEntry {
9194
}
9295
}
9396

94-
function mark(name, options = {}) {
97+
function mark(name, options = kEmptyObject) {
9598
const mark = new PerformanceMark(name, options);
9699
enqueue(mark);
97100
return mark;

0 commit comments

Comments
 (0)