uniq vs uniq

JavaScript performance comparison

Test case created and last updated

Info

Test _.uniq optimizations proposed by Underscore issue 837 against recent Lo-Dash _.uniq optimizations for large arrays.

Preparation code

<script src="//dl.dropbox.com/u/513327/jsconf/2012/mod/lodash.uniq.min.js"></script>
<script>
var lodash = _.noConflict();
</script>
<script src="//dl.dropbox.com/u/513327/jsconf/2012/mod/underscore.charliesome.js"></script>
<script>
var modded = _.noConflict();
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
<script>
(function(window) {
  var array = Array(5e3);
  for (var index = 0; index < 5e3; index++) {
    array[index] = index + '';
  }
  window.array20 = (window.array20 = array.slice(0,10)).concat(array20);
  window.array5k = (window.array5k = array.slice(0, 2500)).concat(array5k);
  window.array10k = array.concat(array);
  window.array20k = array.concat(array, array, array);
}(this));
</script>
<script>
Benchmark.prototype.setup = function() {
    var _ = window._,
        lodash = window.lodash,
        modded = window.modded;
   
    var array20  = window.array20,
        array5k  = window.array5k,
        array10k = window.array10k,
        array20k = window.array20k;
};
</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
Lo-Dash 20k
lodash.uniq(array20k);
pending…
Modded 20k
modded.uniq(array20k);
pending…
Underscore 20k
_.uniq(array20k);
pending…
Lo-Dash 10k
lodash.uniq(array10k);
pending…
Modded 10k
modded.uniq(array10k);
pending…
Underscore 10k
_.uniq(array10k);
pending…
Lo-Dash 5k
lodash.uniq(array5k);
pending…
Modded 5k
modded.uniq(array5k);
pending…
Underscore 5k
_.uniq(array5k);
pending…
Lo-Dash 20
lodash.uniq(array20);
pending…
Modded 20
modded.uniq(array20);
pending…
Underscore 20
_.uniq(array20);
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