Wil Shipley, founder of OmniGroup and author of Delicious Library, on optimizing code:
The time and place are AFTER YOU ARE DONE. Optimize methods ONLY after they work and are bulletproof AND you’ve done testing in Shark and discovered the method is critical.
Don’t optimize as you write. Why not? Because, in all probability, you’re wasting your time. The VAST majority of the code programmers optimize is executed so rarely that its total speedup to the program can be measured only in nanoseconds. Also, you’re probably not very good at it. No insult, but machines and libraries are complex systems, and your guesses as to what’s slow are probably pretty bad. You need to run testing tools to find out what is ACTUALLY slow. The results are often surprising.
I can’t believe I just found Wil’s blog now. Lots of gems in here!