arguments performance (v6)

Revision 6 of this benchmark created by Roland Pihlakas on


Setup

var res = []
  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_helper(a, b, c, d){
      res = [a, b, c, d];
  }
  function f6(){
      f6_helper.apply(null, arguments);
  }

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
apply 2
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.