forEach vs loop vs underscore (v96)

Revision 96 of this benchmark created on


Description

Better test body

Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>

Setup

var arr = [];
    for (var i = 0; i < 100000; i++) arr[i] = i;
    var sum = 0;
    var fn = function(v) {
      sum += v;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
arr.forEach(fn);
ready
loop
for (var i = 0, l = arr.length; i < l; i++) {
  sum += arr[i];
}
ready
underscore
_.each(arr, function (item) {
 sum += item;
});
ready

Revisions

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