Lodash vs Javascript

Benchmark created by Matt C on


Preparation HTML

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

Setup

var data = [], results;
        for(var i=0; i<1000; i++){
          var val = Math.floor(i/5);
          i % 2 ? data.push(i) : data.push(val);
        }

Test runner

Ready to run.

Testing in
TestOps/sec
_.uniq and _.foreach
_.uniq(data);
_(data).forEach(function(num) { console.log(num); });
ready
_.reduce
_.reduce(data, function(lastId, value) {
  if(value !== lastId) {
    console.log(value);
  }
  return value;
});
ready
foreach
data.forEach(function(value) {
    console.log(value);
});
ready

Revisions

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

  • Revision 1: published by Matt C on