Skip to content

Commit

Permalink
fixup! perf_hooks: reduce overhead of new user timings
Browse files Browse the repository at this point in the history
  • Loading branch information
H4ad committed Oct 1, 2023
1 parent 5fd5fad commit df6db01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 6 additions & 2 deletions lib/internal/perf/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,13 @@ function maybeIncrementObserverCount(type) {
}
}

const kSkipThrow = Symbol('kSkipThrow');

class PerformanceObserverEntryList {
constructor() {
throw new ERR_ILLEGAL_CONSTRUCTOR();
constructor(skipThrowSymbol = undefined) {
if (skipThrowSymbol !== kSkipThrow) {
throw new ERR_ILLEGAL_CONSTRUCTOR();
}
}

getEntries() {
Expand Down
10 changes: 3 additions & 7 deletions lib/internal/perf/usertiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ function getMark(name) {
return ts;
}

const kEmptyArg = Symbol('kEmptyArg');

class PerformanceMark extends PerformanceEntry {
constructor(name = kEmptyArg, options = undefined) {
if (name === kEmptyArg) {
constructor(name, options = undefined) {
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('name');
}
name = `${name}`;
if (nodeTimingReadOnlyAttributes.has(name))
throw new ERR_INVALID_ARG_VALUE('name', name);
if (options !== undefined) {
if (options != null) {
validateObject(options, 'options');
}
const startTime = options?.startTime ?? now();
Expand All @@ -86,8 +84,6 @@ class PerformanceMark extends PerformanceEntry {
markTimings.set(name, startTime);

let detail = options?.detail;
// The usage of != is intentional, we want to skip structuredClone
// for both undefined and null
detail = detail != null ?
structuredClone(detail) :
null;
Expand Down

0 comments on commit df6db01

Please sign in to comment.