.map: Underscore.js versus jQuery

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//underscorejs.org/underscore-min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var vals = new Array(999)
    for(var i = 0; i < vals.length; i++){vals[i] = {id: i}}
};
</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
jQuery
$.map(vals, function (i, x) { return x.id })
pending…
Underscore.js
_.map(vals, function (x, i) { return x.id })
pending…
Native
vals.map(function (x, i) { return x.id })
pending…
No Map
var result = [];
for (var i = 0; i < vals.length; i++) {
  result.push(vals[i].id);
}
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