Function calls vs inline

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var m = 1;
    var o = 1;
    var p = 1;
    var q = 1;
    var r = 1;
    var s = 1;
   
    function test() {
      m++;
      o++;
      p++;
      q++;
      r++;
      s++;
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
function call
var i = 0;
for (i = 0; i < 1000; i++) {
  test()
}
pending…
inline
var i = 0;
for (i = 0; i < 1000; i++) {
  m++;
  o++;
  p++;
  q++;
  r++;
  s++;
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

Trey Keown commented :

IE 9 is faster with funciton calls... what?!?

Add a comment