underscore / lodash

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js">
</script>
<script>
  var underscore = _.noConflict();
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.3/lodash.min.js">
</script>
<script>
  var lodash = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var lodash = window.lodash,
        underscore = window.underscore;
   
    var r,
        array = [];
   
    for (var i = 0; i < 20; i++) {
      array[i] = i;
    }
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
forEach underscore
r = [];
underscore.forEach(array, function(v) { r.push(v); });
pending…
forEach lodash
r = [];
lodash.forEach(array, function(v) { r.push(v); });
pending…
forEach native
r = [];
array.forEach(function(v) { r.push(v); });
pending…
forEach lodash (this binding)
r = [];
lodash.forEach(array, function(v) { r.push(v); }, this);
pending…
forEach native (this binding)
r = [];
array.forEach(function(v) { r.push(v); }, this);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment