underscore_mod-no-native (v12)

Revision 12 of this benchmark created on


Description

For a more thorough suite of benchmarks, visit http://lodash.com/benchmarks.

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/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.