sort test

Benchmark created on


Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.1/crossfilter.min.js"></script>

Setup

var array = [];
    
    for (var i=0; i<10000; i++) {
      array.push(i);
    }
    for (var i=0; i<10000; i++) {
      if (i%2 === 0) {
        array.push(i);
      }
    }
    function shuffle(o){
        for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
        return o;
    };
    var testArray = shuffle(array);

Teardown


    var array = [];
    var testArray = [];
    var newArray = [];
  

Test runner

Ready to run.

Testing in
TestOps/sec
underscore only
var newArray = _.uniq(testArray);
ready
regular js sort
testArray.sort(function(a,b) {return a-b});
var newArray = _.uniq(testArray, true);
ready
crossfilter sort
crossfilter.quicksort(testArray, 0, testArray.length);
var newArray = _.uniq(testArray, true);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.