Function Declaration Rate Values ​​in JS

I did a simple jsperf test and everything went as expected when it worked in Firefox, but when I ran the test in Google Chrome, it was confused.

The test tests various ways of declaring a function in JavaScript and then calls them. I assume that Chrome is doing some kind of optimization for the JavaScript function, but I'm not sure if and why there is such a big difference. Any help or links to understand this are best appreciated.

Link to test => http://jsperf.com/function-assignment-semicolon/2

Test in Firefox:

alt text

Test in Chrome:

alt text




Edit:

I expected results from Firefox because I expected them to be - the same for each test - slower than when launched in Google Chrome

+4
performance javascript browser jsperf
Dec 09 '10 at 8:03
source share
1 answer

Dead code, the perfect optimizer will remove everything in the test. This was stated on various news sites with the recent announcement of the Google crankshaft engine. The differences between the styles indicate how difficult it is to implement code optimization.

http://tech.slashdot.org/story/10/12/07/2027259/Google-Quietly-Posts-Big-JavaScript-Engine-Update

+2
Dec 09 '10 at 8:19
source share



All Articles