- Performance is loosely related to code speed
- Efficient code is not necessarily "better" code
- Reducing the lines of code is not necessarily related to performance
- Sometimes, performance depends on environment
- Sometimes, a hardware upgrade is a way to increase performance
- Avoid pre-optimization of code
- Readable,clean code and a correct program is more important than faster programs
Steps to improve performance of a program
1. Develop the software using well-designed code that’s easy
to understand and modify.
2. If performance is poor,
a. Save a working
version of the code so that you can get back to the “last known good state.”
b. Measure the system
to find hot spots.
c. Determine whether
the weak performance comes from inadequate design, data types, or algorithms
and whether code tuning is appropriate. If code tuning isn’t appropriate, go
back to
step 1.
step 1.
d. Tune the bottleneck identified in step (c).
e. Measure each improvement one at a time.
f. If an improvement doesn’t improve the code, revert to the
code saved in step (a). (Typically, more than half the attempted tunings will
produce only a negligible improvement in performance or degrade performance.)