The Fallacy of Premature Optimization
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."
Wed Sep 23 11:12:28 2015 - permalink -
==> Small efficiencies aren't worth the effort during the initial design and implementation of a system, about 97% of the time.
What Hoare and Knuth are really saying is that software engineers should worry about other issues (such as good algorithm design and good implementations of those algorithms) before they worry about micro-optimizations such as how many CPU cycles a particular statement consumes.
So how does an inexperienced programmer learn when early optimization is appropriate? The first step is to profile everything; only by timing sections of the program can a programmer learn to predict the performance of similar code segments.
"Design first, code second." Systems that are designed without any thought of performance rarely perform well, even with an extensive optimization phase at the end of the software development cycle.