native vs. map vs. underscore vs lo-dash vs jquery

JavaScript performance comparison

Revision 26 of this test case created

Info

This test compares the performance of a naive array loop/push vs. array map vs. underscore vs lo-dash vs jquery

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script>
var underscore = _.noConflict();
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script>
var lodash = _.noConflict();
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var arr = underscore.shuffle(underscore.range(50));
};
</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
native loop/push
var r = []
for (var i = 0; i < arr.length; i++) {
  var num = arr[i]
  r.push(num * num)
}
pending…
array map
var r = arr.map(function(num) {
  return num * num;
});
pending…
underscore
var r = underscore.map(arr, function(num) {
  return num * num;
});
pending…
lo-dash
var r = lodash.map(arr, function(num) {
  return num * num;
});
pending…
jQuery
var r = $.map(arr, function(num) {
  return num * 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