Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a loop that runs the benchmark for different values of N #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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