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 <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
LiviaMedeiros authored and danielleadams committed Jun 13, 2022
1 parent b468b8f commit a3310d1
Show file tree
Hide file tree
Showing 4 changed files with 18 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 @@ -212,7 +213,7 @@ class PerformanceObserver {
this.#callback = 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 @@ -34,6 +34,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 @@ -52,7 +56,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
9 changes: 6 additions & 3 deletions lib/internal/perf/usertiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const {
} = require('internal/errors');

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

const markTimings = new SafeMap();

Expand Down Expand Up @@ -61,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 @@ -91,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 a3310d1

Please sign in to comment.