Function parameters vs Arguments object

JavaScript performance comparison

Revision 2 of this test case created

Info

Compare performance of using 'arguments' object or function parameters

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    argFunc = function() {
      this.a = arguments[0];
      this.b = arguments[1];
      this.c = arguments[2];
    },
    paramFunc = function(aParam, bParam, cParam) {
      this.a = aParam;
      this.b = bParam;
      this.c = cParam;
    }
};
</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
Arguments object
new argFunc('ParamA', 77, true);
pending…
Function parameters
new paramFunc('ParamA', 77, true);
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

valesek commented :

On my Mac with OS X 10.6 and firefox 24 are these results 1.test run Arguments object = 2,017,222 ±53.71% fastest Function parameters = 3,633,839 ±21.13% fastest

2.test run and next runs Arguments object = 4,050,744 ±4.26% fastest Function parameters = 4,025,548 ±4.07% fastest

Aleš

Add a comment