underscore_mod-no-native

JavaScript performance comparison

Revision 2 of this test case created by John-David Dalton

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.1.1/lodash.mobile.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

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.1.1/lodash.mobile.min.js"></script> <script> var lodash = _.noConflict(); </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
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.

0 Comments