underscore_mod-no-native (v17)

Revision 17 of this benchmark created by cristian florin on


Preparation HTML

<script src="http://underscorejs.org/underscore.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.min.js"></script>
<script>
var lodash = _.noConflict();
</script>

Setup

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(); });

Test runner

Ready to run.

Testing in
TestOps/sec
each
var timesTwo = [];
_.each(numbers, function(num) { timesTwo.push(num * 2); });
ready
each lodash
var timesTwo = [];
lodash.each(numbers, function(num) { timesTwo.push(num * 2); });
ready
each object
var timesTwo = [];
_.each(object, function(num) { timesTwo.push(num * 2); });
ready
each object lodash
var timesTwo = [];
lodash.each(object, function(num) { timesTwo.push(num * 2); });
ready
keys
_.keys(object);
ready
keys lodash
lodash.keys(object);
ready
map
_.map(objects, function(obj) { return obj.num; });
ready
map lodash
lodash.map(objects, function(obj) { return obj.num; });
ready
pluck
_.pluck(objects, 'num');
ready
pluck lodash
lodash.pluck(objects, 'num');
ready
values
_.values(objects);
ready
values lodash
lodash.values(objects);
ready

Revisions

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