lazy-demo (v20)

Revision 20 of this benchmark created on


Preparation HTML

<script src="https://cdn.rawgit.com/lodash/lodash/4.0.1/lodash.js"></script>

Setup

var arr = _.range(1000).map(function (i) {
        return {
        id: i,
        state: i % 3
      }
    });

Test runner

Ready to run.

Testing in
TestOps/sec
regular
var r = [];

_.forEach(arr, function (a) {
  if (a.state === 1) {
    r.push(a.id);
  }
});
ready
lazy
var r = _(arr).filter(function (a) {
  return a.state === 1;
}).map(function (a) {
  return a.id;
}).value();
ready

Revisions

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