Is there a package that helps me benchmark JavaScript code? I’m not referring to Firebug and such tools.
I need to compare 2 different JavaScript functions that I have implemented. I’m very familiar with Perl’s Benchmark (Benchmark.pm) module and I’m looking for something similar in JavaScript.
Has the emphasis on benchmarking JavaScript code gone overboard? Can I get away with timing just one run of the functions?
Just time several iterations of each function. One iteration probably won’t be enough, but (depending on how complex your functions are) somewhere closer to 100 or even 1,000 iterations should do the job.Firebug also has a profiler if you want to see which parts of your function are slowing it down.Edit: To future readers, the below answer recommending JSPerf should be the correct answer. I would delete mine, but I can’t because it has been selected by the OP. There is much more to benchmarking than just running many iterations, and JSPerf takes care of that for you.