Email or username:

Password:

Forgot your password?
Top-level
Josh Jersild

@marjolica @zens @arnelson bubble sort is great if you only have like 20 items, or the list is nearly sorted already 😃

8 comments
Josh Jersild

@marjolica @zens @arnelson also if it's not fast enough it'll show up on the profiler and you'll fix it

MarjorieR

@JoshJers @zens @arnelson Correct: I found that the bubble sort was the reason it took so long by profiling the program.

MarjorieR

@JoshJers @zens @arnelson back in 1974 I inherited a large Fortran program (about 2000 punch cards) that ran on IBM370 mainframes. The purpose was to calculate the UK power stations fuel use. It used to take 2 minutes of CPU time to run the entire program. It included a bubble sort to put the list of the power stations into 'merit order'. There were about 3000 items in the list. When I replaced bubble sort by quick sort I reduced the total run time to 2 seconds with big savings to our budget.

Josh Jersild

@marjolica @zens @arnelson Yeah, 3000 is definitely the wrong number of elements for bubble sort to be a good choice, *especially* in 1974 😁

MarjorieR

@JoshJers @zens @arnelson the program used to run in a 150kb partition. 2 minutes CPU cost about £100 (1974 prices) for each run.

Luci for dyeing

@marjolica @JoshJers @arnelson well, the rule of thumb is “probably” not “definitely”. sometimes we work ourselves up about scaling problems that just never happen

Josh Jersild

@zens @marjolica @arnelson exactly! The ultimate point is "write it the most straightforward way you can to start, then fix performance problems when they become apparent"

Luci for dyeing replied to Josh

@JoshJers @marjolica @arnelson and also, once again, these are strategies for when you get stuck, not general rules of thumb

Go Up