lazy (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="http://dtao.github.io/lazy.js/lazy.js"></script><script src="http://dtao.github.io/lazy.js/docs/lib/underscore.js"></script><script src="http://dtao.github.io/lazy.js/docs/lib/lodash.js"></script><script>window.lodash = _.noConflict();</script>

Setup

function square(x) { return x * x; }
    function inc(x) { return x + 1; }
    function isEven(x) { return x % 2 === 0; }
    var array = Lazy.range(1000).toArray();

Test runner

Ready to run.

Testing in
TestOps/sec
underscore
var result = _.chain(array).map(square).map(inc).filter(isEven).value();
ready
loop
var results = [];
for (var i = 0; i < array.length; ++i) {
  var value = (array[i] * array[i]) + 1;
  if (value % 2 === 0) {
    results.push(value);

  }
}
ready
lazy
var result = Lazy(array).map(square).map(inc).filter(isEven).toArray();
ready
lodash
var result = lodash(array).map(square).map(inc).filter(isEven).value();
ready

Revisions

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