Performance Tuning Strategies.

来源:互联网 发布:mac office 2016 账号 编辑:程序博客网 时间:2024/05/16 01:56

Think about efficiency from each of these viewpoint
1. Program requirements. Performance is stated as a requirement far more often than is actually is a requirement. Before you invest time solving a performance problem, make sure that you're solveing a problem that needs to be solved.
2. Program design. If you know that a program's size and speed are important, design the program's architecutre so that you can reasonably meet your size and speed goals. Design a performance-oriented architechture, and then set resource goals for individual subsystems, features and classes.
3. Class and routine design. One key to performance that comes into play at this level is the choice of data types and algorithms, which usually affect both the memory use and the execution speed of a program.
4. Operation-system interactions. If your program works with external files, dynamic memory or output device, it's probably interacting with the operation ystem.
5. Hardware. Sometimes the cheapest and best way to improve a program's performance is to buy new hardware.
6. Code tuning. Code tuning is the practice of modifying correct code in ways that meke it run more efficiently.

Steps to code tuning:
1. Develop the sofeware 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 the 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 it isn't appropriate, go back to 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).
3. Repeat from step 2.