lazy-vs-lodash

JavaScript performance comparison

Revision 9 of this test case created by

Preparation code

<script src="https://rawgithub.com/dtao/lazy.js/master/lazy.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var _ = window._,
      Lazy = window.Lazy;
  
  var index = -1,
      length = 100,
      array = Array(length);
  
  while (++index < length) {
    array[index] = index;
  }
  
  function square(x) { return x * x; }
  function inc(x) { return x + 1; }
  function isEven(x) { return x % 2 === 0; }
  

};
</script>

Preparation code output

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js"></script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Lazy - each
Lazy(array).map(square).map(inc).filter(isEven).each(function(e) {});
pending…
Regular - each
_.each(_.filter(_.map(_.map(array, square), inc), isEven), function(e) {});
pending…
Lazy take 5 - each
Lazy(array).map(square).map(inc).filter(isEven).take(5).each(function(e) {});
pending…
Regular take 5 - each
_.each(_.take(_.filter(_.map(_.map(array, square), inc), isEven), 5), function(e) {});
pending…
Lazy - toArray
Lazy(array).map(square).map(inc).filter(isEven).toArray()
pending…
Regular (no iteration)
_.filter(_.map(_.map(array, square), inc), isEven);
pending…
Lazy take 5 - toArray
Lazy(array).map(square).map(inc).filter(isEven).take(5).toArray();
pending…
Regular take 5 (no iteration)
_.take(_.filter(_.map(_.map(array, square), inc), isEven), 5);
pending…

Compare results of other browsers

Revisions

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

0 Comments