Summary of the Approach to Code Tuning
You should take the following steps as you consider whether code tuning can help you improve the performance of a program:
Develop the software by using well-designed code that's easy to understand and modify.
If performance is poor,
Save a working version of the code so that you can get back to the "last known good state."
Measure the system to find hot spots.
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.
Tune the bottleneck identified in step (c).
Measure each improvement one at a time.
If an improvement doesn't improve the code, revert to the code saved in step (a). (Typically, ...