arguments vs. array performance (v3)

Revision 3 of this benchmark created on


Setup

var res = []
  function argumentsSimpleLoop(){
      for(var i = 0, l = arguments.length; i < l; i++){
          res.push(arguments[i])
      }
  }
  
  function arrayForEach(arr){
      arr.forEach(function(n) {
          res.push(n);
      });
  }
  
  function argumentsToArray() {
      var arr = Array.prototype.slice.call(arguments);
      arr.forEach(function(n) {
          res.push(n);
      });
  }
  function argumentsAssignToArray() {
      return Array.prototype.slice.call(arguments);
  }

Teardown



            res = []
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
arguments simple loop
argumentsSimpleLoop(0,1,2,3,4,5,6,7,8,9)
ready
array forEach
arrayForEach([0,1,2,3,4,5,6,7,8,9])
ready
arguments to array
argumentsToArray(0,1,2,3,4,5,6,7,8,9)
ready
argumentsAssignToArray
res = argumentsAssignToArray(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.