const output = {};
const setup = function(){};
const setupQuicksort = function(){
let tmp;
};
//const setupMergesort = function(){
// let tmp1;
// const tmp2 = new Float32Array(N); // For some reason N is not defined
//};
suite
.add('NOP (slice)', function() {
output[this.name] = ta.slice();
}, {setup})
.add('NOP (slice + shuffle)', function() {
tmp = ta.slice();
shuffle(tmp, 0, tmp.length);
output[this.name] = tmp;
}, {setup: setupQuicksort})
.add('Array.prototype.sort', function() {
output[this.name] = a.slice().sort(increasing);
}, {setup})
.add('Float32Array.prototype.sort', function() {
output[this.name] = ta.slice().sort(increasing);
}, {setup})
.add('npm/radixsort', function() {
output[this.name] = radixsort(ta.slice());
}, {setup})
.add('npm/@aureooms/js-quicksort (hoare)', function() {
tmp = ta.slice();
shuffle(tmp, 0, tmp.length);
quicksort_hoar(increasing, tmp, 0, tmp.length);
output[this.name] = tmp;
}, {setup: setupQuicksort})
.add('npm/@aureooms/js-quicksort (lomuto)', function() {
tmp = ta.slice();
shuffle(tmp, 0, tmp.length);
quicksort_lomu(increasing, tmp, 0, tmp.length);
output[this.name] = tmp;
}, {setup: setupQuicksort})
.add('npm/@aureooms/js-quicksort (yaroslavskiy)', function() {
tmp = ta.slice();
shuffle(tmp, 0, tmp.length);
quicksort_yaro(increasing, tmp, 0, tmp.length);
output[this.name] = tmp;
}, {setup: setupQuicksort})
.add('npm/@aureooms/js-mergesort (recursive)', function() {
const tmp1 = ta.slice();
const tmp2 = new Float32Array(N);
mergesort_recu(increasing, tmp1, 0, tmp1.length, tmp2, 0, tmp2.length);
output[this.name] = tmp2;
}, {setup})
.add('npm/@aureooms/js-mergesort (iterative)', function() {
const tmp1 = ta.slice();
const tmp2 = new Float32Array(N);
mergesort_iter(increasing, tmp1, 0, tmp1.length, tmp2, 0, tmp2.length);
output[this.name] = tmp2;
}, {setup})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + Benchmark.filter(this.filter(x => x.name.slice(0,3) !== 'NOP'), 'fastest').map(x => x.name));
})
// do not run async
.run({ 'async': false });