node.js可靠的microtime setTimeout?

node.js reliable microtime setTimeout?

如何在给定时间(以毫秒为单位)后准确地拍摄事件?有什么模块吗?我在 google 上寻找它,但没有找到令人满意的东西...

您无法控制事件循环中代码的准确执行。如果你需要这个,那么你应该考虑使用不同的 Framework/Language.

Understanding the Node.js Event Loop, Timers and process.nextTick()

无法保证 setTimeout() 何时会 运行,只能保证最短等待时间,请参阅上述指南的以下摘录:

setTimeout() schedules a script to be run after a minimum threshold in ms has elapsed.

The closest you have is process.nextTick() and even then you're at the mercy of the Event Queue because other things queued with process.nextTick() can occur before yours. 这也很危险,因为如果实施不当,事件循环可能会饿死。