I’m doing some testing and optimizing on a JavaScript function I made. I notice that the add-on I’m using in Firefox (FireUnit) gives a return of the number of calls done during the profiling time. Is this the number of http calls made by the script?
Also, can you outline/discuss/grade/explain as to how many calls is considered within a good range? Maybe by giving examples or commonly-used JavaScript functions such as drop-down menus, hide/show images, image slideshow functionality, etc…
Does a call represent any measure of ‘work’ or merely the iterations performed?
In this context, a call is the amount of times a function has been invoked.
The function foo has been called/ invoked twice in the above example.
There is no answer for “what is a good range of calls”. A function like
jQuerywill most likely be called a large number of times per page, whereas you would expect a function likeinit()to be called only once.A better representation of the efficiency of your functions is their execution time; this records the amount of time taken for the function to execute (almost always recorded in milliseconds). Functions with long execution times could be optimized to lower their execution time and improve the efficiency of your program.
To best spend you time, you could combine the two statistics (call count and execution time), and look at optimizing the functions that are called a large number of times, and have longer execution times.