简体   繁体   English

匿名函数和node.js性能

[英]Anonymous functions and node.js performance

Are performance effects when using JavaScript anonymous functions also applicable for node.js programs when most of the code in the wild is network/http oriented and processing requests, connections and such is mostly done through anonymous functions? 使用JavaScript匿名函数时的性能影响是否也适用于node.js程序,当大部分代码都是面向网络/ http并且处理请求,连接等主要通过匿名函数完成时? Can this lead to potential performance drop during higher traffic load? 这会导致在更高的流量负载下潜在的性能下降吗?

It really depends on your code, and without measuring it, you cannot know. 这实际上取决于你的代码,如果没有测量它,你就无法知道。 But in general, you can be quite sure that the time spent waiting for I/O significantly outweighs the time spent creating callback functions for handling these I/O events. 但总的来说,您可以非常确定等待I / O所花费的时间明显超过了创建用于处理这些I / O事件的回调函数所花费的时间 Therefore, in normal scenarios there is probably no significant (or even no measurable) gain in optimizing the creation of callbacks. 因此,在正常情况下,优化回调的创建可能没有显着(甚至没有可测量的)增益。 There are likely other areas where it is easier to gain performance and to find them you have to profile your code. 有可能在其他方面更容易获得性能,找到它们就必须对代码进行分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM