prime-vs-underscore-vs-lodash

JavaScript performance comparison

Test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.4/require.min.js"></script>
<script>
var lodash = _.noConflict();
$('#run').hide();
require({
  'baseUrl': '//dl.dropbox.com/u/513327/mootools/prime/'
},
['es5/array'], function(array) {
  window.prime = array;
  $('#run').show();
});
</script>
<script>
Benchmark.prototype.setup = function() {
    var x = 'x';
    var array = Array(31).join(x).split();
   
    var _ = window._;
    var _chaining = _(array).chain();
   
    var lodash = window.lodash;
    var lodashChaining = _(array);
   
    var prime = window.prime;
    var primeChaining = prime(array);
};
</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
Prime
var result = prime.filter(array, function(value) {
  return value == x;
});
pending…
Prime w/ Chaining
var result = primeChaining.filter(function(value) {
  return value == x;
});
pending…
Underscore
var result = _.filter(array, function(value) {
  return value == x;
});
pending…
Underscore w/ Chaining
var result = _chaining.filter(function(value) {
  return value == x;
});
pending…
Lo-Dash
var result = lodash.filter(array, function(value) {
  return value == x;
});
pending…
Lo-Dash w/ Chaining
var result = lodashChaining.filter(function(value) {
  return value == x;
});
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