function-vs-object

JavaScript performance comparison

Revision 2 of this test case created by Gabriel Schulhof

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  window.theFn = function( a, b, c ) {
    var x = a, y = b, z = c;
  };
  window.theInc = 0;
  window.theObjStr = "window.theFn( \"a\", {}, {});\n" +
  " window.someRandomVar = ";
  window.theFnStr = "window.theFn( \"a\", {}, function() { return {}});\n" +
  " window.someRandomVar = ";

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
1. Passing object
eval( window.theObjStr + ( window.theInc++ ) + ";" );
pending…
2. Passing function
eval( window.theFnStr + ( window.theInc++ ) + ";" );
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.

0 Comments