mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
f4af4b111c
PR-URL: https://github.com/nodejs/node/pull/51713 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
35 lines
810 B
JavaScript
35 lines
810 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
constants: {
|
|
NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN,
|
|
NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN_TIMESTAMP,
|
|
},
|
|
milestones,
|
|
now,
|
|
} = internalBinding('performance');
|
|
|
|
function getTimeOrigin() {
|
|
// Do not cache this to prevent it from being serialized into the
|
|
// snapshot.
|
|
return milestones[NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN] / 1e6;
|
|
}
|
|
|
|
// Returns the milestone relative to the process start time in milliseconds.
|
|
function getMilestoneTimestamp(milestoneIdx) {
|
|
const ns = milestones[milestoneIdx];
|
|
if (ns === -1)
|
|
return ns;
|
|
return ns / 1e6 - getTimeOrigin();
|
|
}
|
|
|
|
function getTimeOriginTimestamp() {
|
|
return milestones[NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN_TIMESTAMP] / 1e3;
|
|
}
|
|
|
|
module.exports = {
|
|
now,
|
|
getMilestoneTimestamp,
|
|
getTimeOriginTimestamp,
|
|
};
|