Array.prototype.filter vs. _.filter

Benchmark created by Trey Hunner on


Preparation HTML

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

Setup

var array = _.shuffle(_.range(1000));

Test runner

Ready to run.

Testing in
TestOps/sec
filter
var r = array.filter(function (val) {
  return val > 500;
});
ready
_.filter
var r = _.filter(array, function (val) {
  return val > 500;
});
ready

Revisions

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