A better test of ClojureScript Mori vs. Underscore vs. Lodash vs. Lazy.js (v2)

Revision 2 of this benchmark created on


Description

A better version of the test. http://jsperf.com/clojurescript-mori-vs-underscore-vs-lodash-vs-lazyjs didn't actually do the same thing in every test.

Simple collections manipulation using basic functional programming techniques:

a) make a list of integers from 0 to 999999

b) multiply them by 100

c) take last 100000

d) take first 10000

e) filter those from d that divide by 7

f) filter those from d that divide by 11

g) take the intersection of numbers from both sets e and f

h) count elements of g

Please add more libraries and native code if you can. :)

Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.3/underscore-min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sugar/1.3.7/sugar.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.1.0/lodash.min.js"></script>
<script>var lodash = _.noConflict();</script>
<script src="https://rawgithub.com/fdecampredon/immuable/master/benchmark/mori.js" ></script>
<script src='//rawgithub.com/dtao/lazy.js/master/lazy.js'></script>
<script>
  window.m = mori;
  window.lo = lodash;
  window.L = Lazy;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Mori
var a = m.range(1000000);
var b = m.map(function (n) { return n * 100; }, a);
var c = m.drop(900000, b);
var d = m.take(10000, c);
var e = m.filter(function (n) { return n % 7 == 0; }, d);
var f = m.filter(function (n) { return n % 11 == 0; }, d);
var g = m.intersection(m.set(e), m.set(f));
var h = m.count(g);
 
ready
Underscore
var a = _.range(1000000);
var b = _.map(a, function (n) { return n * 100; });
var c = _.last(b, 100000);
var d = _.first(c, 10000);
var e = _.filter(d, function (n) { return n % 7 == 0; });
var f = _.filter(d, function (n) { return n % 11 == 0; });
var g = _.intersection(e, f);
var h = _.size(g);

 
ready
Lodash
var a = lo.range(1000000);
var b = lo.map(a, function (n) { return n * 100; });
var c = lo.last(b, 100000);
var d = lo.first(c, 10000);
var e = lo.filter(d, function (n) { return n % 7 == 0; });
var f = lo.filter(d, function (n) { return n % 11 == 0; });
var g = lo.intersection(e, f);
var h = lo.size(g);
 
ready
Lazyjs
var a = L.range(1000000);
var b = a.map(function (n) { return n * 100; });
var c = b.last(100000);
var d = c.first(10000);
var e = d.filter(function (n) { return n % 7 == 0; });
var f = d.filter(function (n) { return n % 11 == 0; });
var g = e.intersection(f);
var h = g.size();
 
ready

Revisions

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