Disclaimer: Creator of jsPerf.com .
Your first test is as follows:
var i = 0; for (i = 0; i < 1000; i++) { test() }
Why include a for loop? This only distorts the result. jsPerf automatically repeats the test code until it runs enough tests to achieve a statistically significant result. Ideally, jsPerf tests are as compact as possible and only check what you really want to test. In this case, you are not at all interested in the performance of the for loop - you just need to find out if the inlay code is faster than calling the function or not.
If you're interested in other tips for building robust jsPerf test cases, check out my # jsconfeu2011 presentation .
Note. I'm not saying that an excessive for loop is the reason you see this result. This may be a factor, but there may be something else that further distorts the result. It could be IE9s "dead code removal" feature.
Anyway, Ive forked your jsPerf test, removed the loops, and made the variables global, trying to avoid optimizing code exceptions. http://jsperf.com/function-calls-vs-inline/3 Could you check this in IE9? I currently do not have an IE9 virtual machine.
Mathias bynens
source share