How to get a microtime in Node.js?

后端 未结 13 1203
情深已故
情深已故 2020-12-04 13:41

How can I get the most accurate time stamp in Node.js?

ps My version of Node.js is 0.8.X and the node-microtime extension doesn\'t work for me (crash on install)

13条回答
  •  不知归路
    2020-12-04 14:36

    Node.js nanotimer

    I wrote a wrapper library/object for node.js on top of the process.hrtime function call. It has useful functions, like timing synchronous and asynchronous tasks, specified in seconds, milliseconds, micro, or even nano, and follows the syntax of the built in javascript timer so as to be familiar.

    Timer objects are also discrete, so you can have as many as you'd like, each with their own setTimeout or setInterval process running.

    It's called nanotimer. Check it out!

提交回复
热议问题