native forEach vs lodash

Benchmark created by David Heppell on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>

Setup

var length = 10000;
    var array = [];
    array.length = length;
    
    for (var i = 0; i < length; i++) {
      array[i] = i;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
native
// we're basically doing a reduce, but testing forEach specifically
var sum = 0;

array.forEach(function(d) {
  sum += d;
});
ready
lodash
// we're basically doing a reduce, but testing forEach specifically
var sum = 0;

_.forEach(array, function(d) {
  sum += d;
});
ready

Revisions

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