Is IE faster with function calls?

We are looking for ways to optionalize my code, I came across this jsPerf test . Without expecting anything else but to repeat my idea of ​​the slowness of function calls, my results with IE 9 really threw me into a loop. Code that used function calls was faster, but only in this browser. I ran it several times with the same result. I do not see that the test was configured incorrectly. What can cause this strange result?

My Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0 user agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0 works on Windows Server 2008.

+7
source share
1 answer

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.

+4
source

All Articles