开发者

Anonymous functions and node.js performance

开发者 https://www.devze.com 2023-02-18 04:27 出处:网络
Are performance effects when using JavaScript anonymous functions also applic开发者_StackOverflowable for node.js programs when most of the code in the wild is network/http oriented and processing req

Are performance effects when using JavaScript anonymous functions also applic开发者_StackOverflowable 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? 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. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号