Time Javascript operations
Sep
01

Sometimes I need to time how long a Javascript operation takes. It’s very easy if you are using jQuery.

1
2
3
console.time("longOperation");
for (var i=0; i<1000; ++i){ var j = i*i; } //do something complicated
console.timeEnd("longOperation");

Then, you’ll see the result in the Firebug console: