underscore_mod-no-native

JavaScript performance comparison

Revision 3 of this test case created

Info

Updated the versions! For a more thorough suite of benchmarks, visit http://lodash.com/benchmarks.

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script>
var lodash = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var numbers = [];
    var object = {};
    for (var i = 0; i < 20; i++) {
      numbers[i] = i;
      object['key' + i] = i;
    }
    var objects = _.map(numbers, function(n) { return { 'num': n }; });
    var randomized = _.sortBy(numbers, function() { return Math.random(); });
};
</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
each
var timesTwo = [];
_.each(numbers, function(num) { timesTwo.push(num * 2); });
pending…
each lodash
var timesTwo = [];
lodash.each(numbers, function(num) { timesTwo.push(num * 2); });
pending…
each object
var timesTwo = [];
_.each(object, function(num) { timesTwo.push(num * 2); });
pending…
each object lodash
var timesTwo = [];
lodash.each(object, function(num) { timesTwo.push(num * 2); });
pending…
keys
_.keys(object);
pending…
keys lodash
lodash.keys(object);
pending…
map
_.map(objects, function(obj) { return obj.num; });
pending…
map lodash
lodash.map(objects, function(obj) { return obj.num; });
pending…
pluck
_.pluck(objects, 'num');
pending…
pluck lodash
lodash.pluck(objects, 'num');
pending…
values
_.values(objects);
pending…
values lodash
lodash.values(objects);
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