Improving Runtime Performance

When you examine a program to improve performance, look at those aspects which have a significant impact every time a program is run.

Often runtime performance can be improved through minor changes to your source programs. The amount of improvement each change provides depends on
  • How your program is organized
  • The functions and language constructs your program uses
Some changes may provide substantial performance improvement to your program, while others may offer almost no improvement.
Note: Some tips may contradict each other because they trade one advantage for another. For example, one tip is to reduce the size of the call stack by using static and global variables, while another tip is to improve execution startup performance by reducing the use of static and global variables.

Before trying to improve runtime performance, compile and benchmark your programs using full optimization. Use performance analysis tools to find out where your performance problems are, and then try and apply different appropriate tips to try and achieve the best performance for your program.