6 ms·
Generally agree with you (benchmarking isn't what it used to be ;-). However the following examples all do nothing (except increasing i) and get different resu
by sebilasse 13y ago
Generally agree with you (benchmarking isn't what it used to be ;-).
However the following examples all do nothing (except increasing i) and get different results.
http://jsperf.com/codethatdoesnothing/2 http://jsperf.com/codethatdoesnothing/2
http://jsperf.com/functionwithwhilethatdoesnothing http://jsperf.com/functionwithwhilethatdoesnothing
- jcampbell1 13y agoThey don't increase i at all. It is impossible to count to 10,000 at a rate of 200Mhz. That implies a 2000Ghz processor. JS Perf is fundamentally broken. It doesn't force a side effect, and from the debugger, the first step it does is something like: while(100,000,000--) { // your code here } The chrome compiler then recognizes the loops can be swapped, and eliminated, thus it runs your code once, yet jsperf thinks it ran it hundreds of millions of times.