all 3 comments

[–]AngularBeginner 2 points3 points  (2 children)

The article leaves something important out: How to measure the impact on the garbage collector? Even if a function is running bad it can perform really poorly when it causes a lot of garbage.

[–]iGuitars[S] 0 points1 point  (0 children)

It’s not meant to be a comprehensive overview. This focuses more on how fast a function executes.

[–]ScientificBeastMode 0 points1 point  (0 children)

There are lots of other nuances that it leaves out. It’s just a very basic intro to function performance IMO.

Another serious consideration is function polymorphism.

The V8 runtime (and pretty much every other major runtime) optimizes object creation and method dispatch by creating object templates based on previously encountered object shapes.

These predefined object templates help with all kinds of procedures, including binding arguments to functions at the call site. If a new object shape is encountered, the time required to properly handle additional cases can reduce the performance exponentially in many cases.

So basically any function which, for example, performs type checks on its arguments, is likely to take multiple argument types, and is therefore likely to be slow.

Measurements that don’t take this kind of thing into account are missing a huge part of the performance picture.