I have been writing my first jQuery plugin and struggling to find a means to time how long different pieces of code take to run.
I can use firebug and console.time/profile. However, it seems that because my code executes so fast I get no results with profile and with time it spits out 0ms. (Firebug profiling issue: "no activity to profile")
Is there a way to get the time at a greater level of detail that milliseconds in javascript?
UPDATE: I’ve put code that I want to test in a loop that loops it a million times, but it’s not an ideal solution.
You need to run your tests a number of times and then calculate how many operations per second are executed.
The easiest way to create such a test case is to use the jsPerf website. It will generate a test case like this: http://jsperf.com/prime-numbers