lazy (v2)

Revision 2 of this benchmark created by P on


Description

Tweaking vanilla test, and others.

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(),
        length = array.length,
        value, result, i, results = [];

Test runner

Ready to run.

Testing in
TestOps/sec
underscore
result = _.chain(array).map(square).map(inc).filter(isEven).take(5).value();
ready
loop
for (i = 0; i < length; ++i) {
  value = ((array[i] * array[i]) + 1) % 2;
  if (!value) {
    if (results.push(value) === 5) {
      break;
    }
  }
}
ready
lazy
result = Lazy(array).map(square).map(inc).filter(isEven).take(5).toArray();
ready
lodash
result = lodash(array).map(square).map(inc).filter(isEven).take(5).value();
ready

Revisions

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