mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
perf_hooks: use kEmptyObject
PR-URL: https://github.com/nodejs/node/pull/43159 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
b468b8fe51
commit
a3310d13bf
4 files changed
+18
-6
No files matched your search
@@ -27,6 +27,10 @@ const {
|
||||
kMap,
|
||||
} = require('internal/histogram');
|
||||
|
||||
const {
|
||||
kEmptyObject,
|
||||
} = require('internal/util');
|
||||
|
||||
const {
|
||||
makeTransferable,
|
||||
} = require('internal/worker/js_transferable');
|
||||
@@ -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;
|
||||
|
||||
@@ -55,6 +55,7 @@ const {
|
||||
customInspectSymbol: kInspect,
|
||||
deprecate,
|
||||
lazyDOMException,
|
||||
kEmptyObject,
|
||||
} = require('internal/util');
|
||||
|
||||
const {
|
||||
@@ -212,7 +213,7 @@ class PerformanceObserver {
|
||||
this.#callback = callback;
|
||||
}
|
||||
|
||||
observe(options = {}) {
|
||||
observe(options = kEmptyObject) {
|
||||
validateObject(options, 'options');
|
||||
const {
|
||||
entryTypes,
|
||||
|
||||
@@ -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)
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user