mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

PR-URL: https://github.com/nodejs/node/pull/50492 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
28 lines
614 B
JavaScript
28 lines
614 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
constants: {
|
|
NODE_PERFORMANCE_MILESTONE_TIME_ORIGIN,
|
|
},
|
|
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();
|
|
}
|
|
|
|
module.exports = {
|
|
now,
|
|
getMilestoneTimestamp,
|
|
};
|