Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bootstrap: lazy-load Performance.prototype.timeOrigin
  • Loading branch information
joyeecheung authored and targos committed Oct 28, 2023
commit 10f5974fac05c98979f2cb38843296b865035754
29 changes: 14 additions & 15 deletions lib/internal/perf/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,24 @@ ObjectDefineProperties(Performance.prototype, {
enumerable: false,
value: timerify,
},
// This would be updated during pre-execution in case
// the process is launched from a snapshot.
// TODO(joyeecheung): we may want to warn about access to
// this during snapshot building.
timeOrigin: {
__proto__: null,
configurable: true,
enumerable: true,
value: getTimeOriginTimestamp(),
get() {
const value = getTimeOriginTimestamp();
ObjectDefineProperty(Performance.prototype, 'timeOrigin', {
__proto__: null,
value,
});
return value;
},
set(value) {
ObjectDefineProperty(Performance.prototype, 'timeOrigin', {
__proto__: null,
value,
});
},
},
toJSON: {
__proto__: null,
Expand All @@ -224,15 +233,6 @@ ObjectDefineProperties(Performance.prototype, {
},
});

function refreshTimeOrigin() {
ObjectDefineProperty(Performance.prototype, 'timeOrigin', {
__proto__: null,
configurable: true,
enumerable: true,
value: getTimeOriginTimestamp(),
});
}

const performance = new InternalPerformance();

function dispatchBufferFull(type) {
Expand All @@ -246,5 +246,4 @@ setDispatchBufferFull(dispatchBufferFull);
module.exports = {
Performance,
performance,
refreshTimeOrigin,
};
1 change: 0 additions & 1 deletion lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ function setupTraceCategoryState() {
}

function setupPerfHooks() {
require('internal/perf/performance').refreshTimeOrigin();
require('internal/perf/utils').refreshTimeOrigin();
}

Expand Down