for(;;;) vs forEach vs $.each (v33)

Revision 33 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var i;
    
    window.arr = [];
    
    for (i = 0; i < 10000; i += 1) {
      arr.push(i);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
for(;;;)
var ii = 0, len = arr.length;

for (ii = 0; ii < len; ii += 1) {
  ii / 2;
}
ready
native forEach
arr.forEach(function (i) {
  i / 2;
});
ready
$.each
$.each(arr, function (i) {
  i / 2;
});
ready
native forEach =>
arr.forEach(i => i /2);
ready
$.each =>
$.each(arr, i =>  i / 2);
ready

Revisions

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