Asynchronous uuid generation in node

时间:2016-08-31 18:55:54

标签: node.js performance

I began using --trace-sync-io to detect synchronous calls in my code and noticed the node-uuid package is making a lot of them via the crypto module. Is synchronous uuid generation expensive enough to warrant refactoring to use async? If so, what is the appropriate approach or package to do this?

1 个答案:

答案 0 :(得分:4)

  

我的节点性能心理模型“绝对不同步   每个请求调用。“

这通常适用于阻止有意义地停止工作的任务。您不希望同步等待400毫秒API调用或读取或写入磁盘(因此FS具有同步和异步选项)。如上所述,node-uuid的基准测试非常快,因此针对异步性进行优化可能会浪费开发人员和程序时间。