lazy-demo

JavaScript performance comparison

Test case created by fil and last updated

Preparation code

<script src="https://cdn.rawgit.com/lodash/lodash/3.0.0/lodash.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var arr = _.range(10000),
      limit = 100;
      
  var odd = function(v) { return !!(v % 2); },
      square = function(v) { return v * v; };

};
</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
regular
var r = _.take(_.filter(_.map(arr, square), odd), limit);
pending…
lazy
var r = _(arr).map(square).filter(odd).take(limit).value();
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