arguments vs. array performance (v2)

Revision 2 of this benchmark created by Matt Swensen 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);
      });
  }

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

Revisions

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