underscore_mod-no-native

JavaScript performance comparison

Revision 4 of this test case created by and last updated

Info

Testing the performance of the first draft of removing native array iteration methods from Underscore.

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

Preparation code

<script src="//rawgithub.com/documentcloud/underscore/69e1677829093ce1d7f1eca0159aa9a282eec967/underscore.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.underscore.js"></script>
<script>
var lodash = _.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var numbers = Array(30);
    var object = {};
    for (var i = 0; i < 30; i++) {
      numbers[i] = i;
      object['key' + i] = i;
    }
    var objects = _.map(numbers, function(n) { return { 'num': n }; });
};
</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 doubles = [];
_.each(numbers, function(num) { doubles.push(num * 2); });
pending…
each lodash
var doubles = [];
lodash.each(numbers, function(num) { doubles.push(num * 2); });
pending…
map
var squares = _.map(numbers, function(num) { return num * num; });
pending…
map lodash
var squares = lodash.map(numbers, function(num) { return num * num; });
pending…
pluck
var result = _.pluck(objects, 'num');
pending…
pluck lodash
var result = lodash.pluck(objects, 'num');
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