Like a linq libraries performance (v7)

Revision 7 of this benchmark created by Scott Sauyet on


Description

Comparing when the entire list is actually needed. While laziness is a virtue, it's also instructive to compare what happens when it's not a part of the equation.

(Also removing wu, which is failing for some reason.)

Preparation HTML

<script src="//cdn.rawgit.com/jlongster/transducers.js/2f1edb1f15c515b0c9c98db955c1abc1442d59e4/dist/transducers.js"></script>
<script src="//cdn.rawgit.com/dtao/lazy.js/7a9b0210d97168ff48c5d2b4ce4d12194ba7fbec/lazy.js"></script>
<script src="//cdn.rawgit.com/CrossEye/ramda/v0.5.0/ramda.js"></script>
<script src="//cdn.rawgit.com/lodash/lodash/84ffec5f8667041abdc6301fd713a83e6091fae0/dist/lodash.js"></script>
<script>var lodash = _.noConflict();</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore.js"></script>

Setup

var arr = _.range(10000),
        limit = 9999;
        
    var odd = function(v) { return !!(v % 2); },
        square = function(v) { return v * v; };

Test runner

Ready to run.

Testing in
TestOps/sec
Native
var r = arr.map(square).filter(odd).slice(0, limit);
ready
Underscore
var r = _(arr).chain().map(square).filter(odd).take(limit).value();
ready
Lazy.js
var r = Lazy(arr).map(square).filter(odd).take(limit).value();
ready
Lo-Dash (lazy)
var r = lodash(arr).map(square).filter(odd).take(limit).value();
ready
Lo-Dash (normal)
var r = lodash.take(lodash.filter(lodash.map(arr,square), odd), limit);
ready
Ramda
var r = R.take(limit, R.filter(odd, R.map(square, arr)));
ready
Transducers
var transform = transducers.compose(
  transducers.map(square),
  transducers.filter(odd),
  transducers.take(limit)
);

var r = transducers.seq(arr, transform);
ready

Revisions

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

  • Revision 1: published by Denis on
  • Revision 4: published by anon on
  • Revision 7: published by Scott Sauyet on
  • Revision 8: published by Scott Sauyet on
  • Revision 12: published by nin-jin on
  • Revision 13: published on
  • Revision 15: published by Denis Stoyanov on