Skip to content

Conversation

@JL102
Copy link

@JL102 JL102 commented Feb 22, 2023

I also sorted (ha) each algorithm based on their general complexity, so that folks who wanna run it can quickly comment out slower algos so that they can test faster ones with better values of N.

Interestingly, on my system, Merge sort gets really bad at 1,000,000 elements with its large amount of memory usage, and the custom quick sort performs better than JS sort!

@JL102
Copy link
Author

JL102 commented Feb 22, 2023

more interesting results. Comparison between nodejs and bun with 1,000,000 elements.

Node:

┌─────────┬─────────────┬────────────────────┐
│ (index) │    name     │        time        │
├─────────┼─────────────┼────────────────────┤
│    0    │ 'quickSort' │ 75.02510000765324  │
│    1    │ 'heapSort'  │ 184.67769999802113 │
│    2    │ 'shellSort' │ 215.91150000691414 │
│    3    │ 'radixSort' │ 345.7732999920845  │
│    4    │  'jsSort'   │  377.917999997735  │
│    5    │ 'mergeSort' │ 227719.7909000069  │
└─────────┴─────────────┴────────────────────┘

Bun:

[
  {
    name: "heapSort",
    time: 160.1846430000005
  }, {
    name: "jsSort",
    time: 178.1277869999999
  }, {
    name: "shellSort",
    time: 221.78199899999981
  }, {
    name: "quickSort",
    time: 264.99975399999994
  }, {
    name: "radixSort",
    time: 840.8059830000002
  }, {
    name: "mergeSort",
    time: 864.977034
  }
]

I find it interesting how Radix does very poorly compared to quicksort and heapsort. It might be something to do with the implementation and the fact that it's using JS and not some native language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant