node.js - Node.js 中的 process.hrtime() 和 process.hrtime.bigint() 函数是指什么时间?

标签 node.js

process.hrtime()process.hrtime.bigint() 的旧版本方法

process.hrtime();                     // -> [27511, 516453000]   (seconds, remaining nanoseconds)
process.hrtime.bigint();              // -> 27511516453000n      (nanoseconds)
  • 27511516453000 纳秒是 7.6420879036111113 小时

    当我测试这个时间是 11:54 UTC 和 14:54 语言环境时间
  • 7.64 小时不是指当前时间,那么 7.64 小时指的是什么?
  • 最佳答案

    这些值的含义在 documentation 中定义。 (虽然很容易错过,因为它只是一行):

    These times are relative to an arbitrary time in the past, and not related to the time of day and therefore not subject to clock drift.



    换句话说,hrtime仅用于计算相对于另一个时间点的时间。如果您调用hrtime现在,然后再过十秒,后者减去前者的结果将等于十秒。然而,这两个调用返回的值彼此隔离并没有真正的意义。

    关于node.js - Node.js 中的 process.hrtime() 和 process.hrtime.bigint() 函数是指什么时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56597772/

    相关文章:

    node.js - 如何通过代理连接到nodejs Express服务器

    mysql - 使用 Node.JS 和 EJS 遍历数组

    javascript - Node.js 模块范式的基础知识?

    javascript - 如何从对象中删除字段

    javascript - 如何将数据从 ReactJS 发布到 NodeJS Express API

    node.js 相当于 python 的 if __name__ == '__main__'

    javascript - 输入行前面的前缀

    javascript - Node.js应用程序中的reduce函数省略json json数据并且太麻烦

    node.js - 仅使用 Nodejs 运行 npm 开发?

    javascript - 为什么嵌入式下拉菜单只选择第一个选项?