Andy gave some good hints, here are a few additions:
- Yes, of course correct code is the most important. The question is the border cases, sometimes the code is mostly correct, but fixing border cases makes then slower. One idea here is to have a general fully correct procedure and then sub methods that well work for particular cases. I my opinion, the default code should always be the fully correct one.
- Timing vs. AbsoluteTiming: HereHere is another example of a shortcoming of Timing. You might want to look at the Workbench profiler.
- Concerning cache and memory, I find
$HistoryLength=0
and alsoMaxMemoryUsed[]
very valuable.