Understanding Program Performance


The performance of a program depends on the algorithm, the language, the compiler, the architecture, and the actual hardware. The following table summarizes how these components affect the factors in the CPU performance equation:
   CPU times = ( Instruction count × CPI ) / Clock rate

Hardware or Software Component Affect What How?
Algorithm Instruction count The algorithm determines the number of source program instructions executed and hence the number of processor instructions executed.
Possibly CPI The algorithm may also affect the CPI, by favoring slower or faster instructions.
Programming language Instruction count Statements in the language are translated to processor instructions, which determine instruction count.
CPI For example, a language with heavy support for data abstraction (e.g., Java) will require indirect calls, which will use higher CPI instructions.
Compiler Instruction count The compiler determines the translation of the source language instructions into computer instructions.
CPI The compiler’s role can be very complex and affect the CPI in complex ways.
Instruction set architecture Instruction count The instruction set architecture affects all three aspects of CPU performance, since it affects the instructions needed for a function, the cost in cycles of each instruction, and the overall clock rate of the processor.
Clock rate
CPI

Question: A given application written in C++ runs 20 seconds on a computer. A new C++ compiler is released that requires only 0.5 as many instructions as the old compiler. Unfortunately, it increases the CPI by 1.2. How fast can we expect the application to run using this compiler?

Answer:   seconds