3 ms·
Chrome 34: function: 5,572,574 method: 903,375,064 Firefox 29: function: 1,747,475,085 method: 1,727,244,041
by acdha 13y ago
Chrome 34:
function: 5,572,574
method: 903,375,064
Firefox 29:
function: 1,747,475,085
method: 1,727,244,041
- bzbarsky 13y agoAny time you see jsperf numbers over about 1e9, that means that the testcase was compeletely optimized out by the JIT (presumably because it has no detectable side-effects so got dead-code eliminated). 1.7e9 iterations per second on typical modern 3Ghz hardware means 2 clock ticks or less per iteration. That's about enough time to increment the loop counter and compare it to the loop limit and nothing else.
- Stratoscope 13y agoIndeed, if you add a completely empty test case, it is only a tiny bit faster than the method version that appears to have such high performance. (jsperf doesn't allow a completely empty test, but you can use // to fool it.)