I came across reading the basic principles of optimization and performance tuning from two books, and I actually thought of sharing it here:
Chapter 1 of Java Performance Tuning:
Don't Tune What You Don't Need to Tune
The most efficient tuning you can do is not to alter what works well. As they say, "If it ain't broke, don't fix it." This may seem obvious, but the temptation to tweak something just because you have thought of an improvement has a tendency to override this obvious statement.
Item 37 of Effective Java Programming:
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason—including blind stupidity.
– William A. Wulf
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
– Donald E. Knuth
We follow two rules in the matter of optimization:
Rule 1. Don't do it.
Rule 2 (for experts only). Don't do it yet—that is, not until you have a perfectly clear and unoptimized solution.
– M. A. Jackson
As mentioned in the book above, performance issues should be thought of while the application is being designed. Therefore,
- A good design is very important. Spend more time on the design or spend even more time to get things really working happily one day
- Don't do optimization if:
- You have not gotten something working yet
- The measurable gain is insignificant
- yc, reading