Skip to content

Instantly share code, notes, and snippets.

@somombo
Last active September 25, 2025 01:55
Show Gist options
  • Select an option

  • Save somombo/3aaa260bb01c7e7af8d87f80e86bfde8 to your computer and use it in GitHub Desktop.

Select an option

Save somombo/3aaa260bb01c7e7af8d87f80e86bfde8 to your computer and use it in GitHub Desktop.
Sort Results One Million
Already Sorted Uniques:
Partition.hoare.eager: 58ms
Partition.hoare.new: 69ms
Array.insertionSort: 6ms
List.mergeSort: 231ms
Partition.lomuto: 66ms
Array.heapSort: 937ms
Array.qsort: 268ms
Already Sorted With Duplicates:
Partition.hoare.eager: 66ms
Partition.hoare.new: 116ms
Array.insertionSort: 6ms
List.mergeSort: 231ms
Partition.lomuto: 639829ms
Array.heapSort: 730ms
Array.qsort: 2658883ms
Almost Sorted Uniques:
Partition.hoare.eager: 61ms
Partition.hoare.new: 77ms
Array.insertionSort: 186ms
List.mergeSort: 288ms
Partition.lomuto: 6639ms
Array.heapSort: 953ms
Array.qsort: 25671ms
Reverse Sorted Uniques:
Partition.hoare.eager: 62ms
Partition.hoare.new: 77ms
Array.insertionSort: 1374911ms
List.mergeSort: 239ms
Partition.lomuto: 130ms
Array.heapSort: 1000ms
Array.qsort: 443ms
Unsorted Uniques:
Partition.hoare.eager: 206ms
Partition.hoare.new: 248ms
Array.insertionSort: 688218ms
List.mergeSort: 951ms
Partition.lomuto: 199ms
Array.heapSort: 1097ms
Array.qsort: 427ms
Unsorted Very High Duplicates:
Partition.hoare.eager: 74ms
Partition.hoare.new: 152ms
Array.insertionSort: 129185ms
List.mergeSort: 380ms
Partition.lomuto: 780042ms
Array.heapSort: 232ms
Array.qsort: 3642751ms
Unsorted High Duplicates:
Partition.hoare.eager: 70ms
Partition.hoare.new: 152ms
Array.insertionSort: 336128ms
List.mergeSort: 347ms
Partition.lomuto: 460444ms
Array.heapSort: 523ms
Array.qsort: 2236889ms
Unsorted Mid Duplicates:
Partition.hoare.eager: 80ms
Partition.hoare.new: 164ms
Array.insertionSort: 523256ms
List.mergeSort: 442ms
Partition.lomuto: 228454ms
Array.heapSort: 752ms
Array.qsort: 1115337ms
--- Size 0 ---
Result: #[]
--- Size 10, Sorted, 0% swaps ---
Result: #[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
--- Size 10, Sorted, 0% swaps ---
Result: #[0, 1, 1, 1, 1, 1, 1, 2, 3, 4]
--- Size 10, Reversed, 0% swaps ---
Result: #[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
--- Size 10, Sorted, 20% swaps (2 swaps) ---
Result: #[0, 1, 4, 3, 2, 6, 5, 7, 8, 9]
--- Size 10, Reversed, 20% swaps (2 swaps) ---
Result: #[9, 8, 7, 4, 5, 6, 0, 2, 1, 3]
--- Size 10, Sorted, 100% swaps (10 swaps) ---
Result: #[6, 0, 2, 3, 5, 1, 7, 8, 4, 9]
--- Size 10, Low Duplicates (effectively a shuffle) ---
Result: #[3, 5, 6, 9, 0, 8, 4, 7, 1, 2]
--- Size 10, All Duplicates ---
Result: #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
--- Size 20, Medium Duplicates (ratio = 0.25). max val be 3 ---
Result: #[1, 0, 3, 1, 3, 0, 2, 1, 3, 2, 1, 2, 0, 1, 2, 0, 2, 3, 3, 0]
--- Size 20, High Duplicates (ratio = 0.8). 16 duplicates, 4 non-duplicates ---
Result: #[0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment