views:

810

answers:

1

Hi all, Is there a package that helps me benchmark JS code ? Im not referring the Firebug and such tools.

I need to compare 2 different JS functions that I have implemented. Im very familiar with perl's Benchmark (http://search.cpan.org/~tty/kurila-1.19_0/lib/Benchmark.pm) module and Im looking for something similar in javascript.

Is the emphasis on benchmarking the JS code overboard ? Can I get away with timing just one run of the functions ?

A: 

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.

musicfreak