arguments to array

JavaScript performance comparison

Revision 17 of this test case created

Preparation code


 
<script>
Benchmark.prototype.setup = function() {
    function a () {
      var args = new Array(arguments.length);
      for (var i = 0, l = arguments.length; i < l; i++) {
        args[i] = arguments[i];
      }
      return args;
    };
   
    function argsAsArray(args) {
      var result = new Array(args.length);
      for (var i = 0, l = args.length; i < l; i++) {
        result[i] = args[i];
      }
      return result;
    }
   
    function b () {  
      return argsAsArray(arguments);
    };
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
a
a(1, 2, 3, 4, 5);
pending…
b
b(1, 2, 3, 4, 5);
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:

0 comments

Add a comment