lowdash VS forEachFor

JavaScript performance comparison

Test case created by tomByrer and last updated

Info

Testing if while to for looping makes a difference.

Preparation code

<script src="https://rawgithub.com/tomByrer/lodash/test-for/lodash.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var items = [];
    var result = 0;
    var n = 5000;
    while (n--) {
     items.push( n + rand());
    }
   
    function rand(){  // just to make sure JIT can't get too clever about it
      return Math.random() < 0.5? -1 : 1;
    }
   
    function sum(val){
      result += val;
    }
};

Benchmark.prototype.teardown = function() {
    //
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
lodash
_.each(items, sum);
pending…
forEachFor
_.each(items, sum); //from fork
pending…

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

Compare results of other browsers

0 comments

Add a comment