Donald Knuth famously stated: We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
The Full Quote (Often Missed)
Knuth also said: Yet we should not pass up our opportunities in that critical 3%. The point is not to never optimize, but to:- Profile first — identify actual bottlenecks
- Optimize the right 3% — focus on hot paths
- Don't sacrifice readability for marginal gains
Write clear code first, then measure, then optimize.