/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/internal/perf/utils.js
34 строки
810 B
IlyasShabi
perf_hooks: performance milestone time origin timestamp improvement
28 фев 2024, 19:52
Не верифицирован
28 фев 2024, 19:52
f4af4b1
Код
Авторство
О чём код?
'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, };