views:

52

answers:

2

Is there a way to get the time a piece of JavaScript actually runs on the CPU, like with the clock() and getrusage() functions in C? Using the normal Date() way only gives the wall time, and for performance measurements the CPU time would be much more useful.

Note that I'm not looking for profiling tools, I want to reduce system noise for automated testing and not optimize specific functions.

A: 

Most modern browsers, notably WebKit based ones, have Javascript profiling built in (e.g. in the Web Inspector). This should be even more useful than clock().

deceze
Thanks, but that's not really suitable in my case: I want to reduce system noise for automatic testing and not optimize specific functions. I guess I should have made that more clear in the question.
majutsushi
A: 

No, you can't. Date is the only thing the standard JavaScript library provides.

casablanca
Too bad, but thanks!
majutsushi