arguments performance (v13)

Revision 13 of this benchmark created on


Setup

var res = []
  var slice = [].slice;
  function f1(){
      for(var i = 0, l = arguments.length; i < l; i++){
          res.push(arguments[i])
      }
  }
  
  function f2(){
      var args = arguments
      for(var i = 0, l = args.length; i < l; i++){
          res.push(args[i])
      }
  }
  
  function f3(){
      var len = arguments.length;
      res = new Array(len);
      for (var i = 0; i < len; i++)
           res[i] = arguments[i];
  }
  
  function f4(){
      res = Array.prototype.slice.call(arguments);
  }
  
  function f5_helper(){
      res = arguments;
  }
  function f5(){
      f5_helper.apply(null, arguments);
  }
  
  function f6() {
    res = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  };

Teardown



            res = []
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
arguments
f1(0,1,2,3,4,5,6,7,8,9)
ready
args
f2(0,1,2,3,4,5,6,7,8,9)
ready
copy with preallocation
f3(0,1,2,3,4,5,6,7,8,9)
ready
slice
f4(0,1,2,3,4,5,6,7,8,9)
ready
apply
f5(0,1,2,3,4,5,6,7,8,9)
ready
coffeescript
f6(0,1,2,3,4,5,6,7,8,9)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.