for vs array-foreach (v20)

Revision 20 of this benchmark created on


Setup

var array = Array(31).join('x').split('');
    
    function callback(value, index, object) {
      return value;
    }
    
    PowerArray.prototype.forEach2 = function(fun) {
      var i = 0,
        len = this.length;
    
      while (i < len) {
        fun(this[i], i);
        i += 1;
      }
    
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Array#forEach2
array.forEach2(callback);
ready
Array#forEach
array.forEach(callback);
ready

Revisions

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