Skip to content

Commit

Permalink
perf_hooks: use kEmptyObject
Browse files Browse the repository at this point in the history
PR-URL: #43159
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
LiviaMedeiros authored and targos committed Jul 31, 2022
1 parent ca4157e commit f08a282
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/internal/perf/event_loop_delay.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const {
kMap,
} = require('internal/histogram');

const {
kEmptyObject,
} = require('internal/util');

const {
makeTransferable,
} = require('internal/worker/js_transferable');
Expand Down Expand Up @@ -69,7 +73,7 @@ class ELDHistogram extends Histogram {
* }} [options]
* @returns {ELDHistogram}
*/
function monitorEventLoopDelay(options = {}) {
function monitorEventLoopDelay(options = kEmptyObject) {
validateObject(options, 'options');

const { resolution = 10 } = options;
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/perf/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const {
customInspectSymbol: kInspect,
deprecate,
lazyDOMException,
kEmptyObject,
} = require('internal/util');

const {
Expand Down Expand Up @@ -215,7 +216,7 @@ class PerformanceObserver {
this[kCallback] = callback;
}

observe(options = {}) {
observe(options = kEmptyObject) {
validateObject(options, 'options');
const {
entryTypes,
Expand Down
6 changes: 5 additions & 1 deletion lib/internal/perf/timerify.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const {
enqueue,
} = require('internal/perf/observe');

const {
kEmptyObject,
} = require('internal/util');

function processComplete(name, start, args, histogram) {
const duration = now() - start;
if (histogram !== undefined)
Expand All @@ -48,7 +52,7 @@ function processComplete(name, start, args, histogram) {
enqueue(entry);
}

function timerify(fn, options = {}) {
function timerify(fn, options = kEmptyObject) {
validateFunction(fn, 'fn');

validateObject(options, 'options');
Expand Down
10 changes: 7 additions & 3 deletions lib/internal/perf/usertiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const {
},
} = require('internal/errors');

const { structuredClone, lazyDOMException } = require('internal/util');
const {
kEmptyObject,
lazyDOMException,
structuredClone,
} = require('internal/util');

const markTimings = new SafeMap();

Expand Down Expand Up @@ -60,7 +64,7 @@ class PerformanceMark extends InternalPerformanceEntry {
name = `${name}`;
if (nodeTimingReadOnlyAttributes.has(name))
throw new ERR_INVALID_ARG_VALUE('name', name);
options ??= {};
options ??= kEmptyObject;
validateObject(options, 'options');
const startTime = options.startTime ?? now();
validateNumber(startTime, 'startTime');
Expand Down Expand Up @@ -90,7 +94,7 @@ class PerformanceMeasure extends InternalPerformanceEntry {
}
}

function mark(name, options = {}) {
function mark(name, options = kEmptyObject) {
const mark = new PerformanceMark(name, options);
enqueue(mark);
return mark;
Expand Down

0 comments on commit f08a282

Please sign in to comment.