sort-algorithms (v13)

Revision 13 of this benchmark created by Ido Sela on


Description

Comparing native, bubble, insertion, selection, merge, and quick sort algorithms on a random array.

Preparation HTML

<script src="https://raw.github.com/idosela/algorithms-in-javascript/master/common.js">
</script>
<script src="https://raw.github.com/idosela/algorithms-in-javascript/master/bubble-sort.js">
</script>
<script src="https://raw.github.com/idosela/algorithms-in-javascript/master/insertion-sort.js">
</script>
<script src="https://raw.github.com/idosela/algorithms-in-javascript/master/merge-sort.js">
</script>
<script src="https://raw.github.com/idosela/algorithms-in-javascript/master/quick-sort.js">
</script>
<script src="https://raw.github.com/idosela/algorithms-in-javascript/master/selection-sort.js">
</script>

Setup

// Generate array with 10,000 random integers.
    var unsortedTestArray = [];
    for (var i = 0; i < 10000; i++) {
      unsortedTestArray.push(Math.floor(Math.random()*100000));
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Native
unsortedTestArray.sort(function compareNumbers(a, b) {
  return a - b;
});
ready
BubbleSort
aij.bubbleSort(unsortedTestArray);
ready
InsertionSort
aij.insertionSort(unsortedTestArray);
ready
SelectionSort
aij.selectionSort(unsortedTestArray);
ready
MergeSort
aij.mergeSort(unsortedTestArray);
ready
QuickSort
aij.quickSort(unsortedTestArray);
ready

Revisions

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