4 ms·
I looked through the code, I see why quicksort is such a blur now, and I don't see an obvious way to fix it. Since you are in a sense, benchmarking these algori
by GhotiFish 13y ago
I looked through the code, I see why quicksort is such a blur now, and I don't see an obvious way to fix it. Since you are in a sense, benchmarking these algorithms.
One way to do it might be to allow the user to set the timeout in your defer function.
Setting the timeout to 1 second lets the user observe each run of your algorithms. You can see the partitioning behaviour a bit better like that.
Side note: this code is pretty. I should learn coffeescript.
- lolo_ 13y agoI really need to jump back into the code, not looked at it for a while and take a look at improving how 'fairly' it benchmarks the algorithms. That's an interesting suggestion, will experiment with it. Thanks for your kind comment on the code qual :) personally I only see the faults, for one I am sure I could improve perf... year-old code is often that way however! :)
- GhotiFish 13y agoI tried to implement shell sort in your system. Shell sort is much like quick sort in that it kind of divides and conquers. (you can see my horrid first timer work here: https://github.com/Ghoughpteighbteau/Rainbow-Sort https://github.com/Ghoughpteighbteau/Rainbow-Sort ) My estimation is that you need to refactor the algorithms such that they hold their state inside a closure, and break after a set number of swaps. Say every 300 swaps they break and the canvas updates. This kind of background processing is such a pain in javascript.
- elwell 13y agoYes, but it should use two spaces for indentation, not a tab; according to coffeescript guidelines.
- GhotiFish 13y agostrange downvotes: the statement is true and informative: https://github.com/polarmobile/coffeescript-style-guide#tabs_or_spaces https://github.com/polarmobile/coffeescript-style-guide#tabs... to someone who was just learning about coffeescript.
- lolo_ 13y agoWhere I work we use tabs; has carried over to my personal projects some. Personally I prefer spaces ;-)