4 ms·
Try turning down the block size (the value that defaults to 20), that will make it far slower - try 5. I know that isn't too obvious, but this was something of
by lolo_ 13y ago
Try turning down the block size (the value that defaults to 20), that will make it far slower - try 5.
I know that isn't too obvious, but this was something of a quick hack :)
- d23 13y agoYeah, the problem is it just sort of "happens" without me being able to understand what's going on behind the scenes. For instance, all of a sudden half the screen is slightly more sorted, but I have no clue what went into getting it that way, even though it took more time to do so.
- lolo_ 13y agoYeah, I think I need to review this code + make it 'fairer' or at least somewhat smoother. The positive reaction here has motivated me to hack on this project again!
- GhotiFish 13y agoI 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 ;-)
- joveian 13y agoI didn't try 5, but at 2 or 1 my browser (Firefox) just hung until it was done and spit out the final image :(. Really neat idea, though :).