The basic performance equation can therefore be written in terms of
instruction count (the number of instructions executed by the program),
CPI (clock cycles per instruction), and
clock cycle time.
CPU times = Instruction count × CPI × Clock cycle time
or, since the clock rate is the inverse of clock cycle time:
CPU times = ( Instruction count × CPI ) / Clock rate
Computing CPU Time
Consider two different implementations, P1 and P2, of the same instruction set architecture.
There are three classes of instructions, A, B, and C.
The clock rate and CPI of each implementation are given in the following table:
Clock Rate
CPI Class A
CPI Class B
CPI Class C
P1
2.0 GHz
1
2
3
P2
1.5 GHz
2
2
2
Given a program with 104 instructions divided into classes as follows: 30% class A, 30% class B, and 40% class C, which implementation is faster?
We can use the equation for CPU clock cycles based on instruction count and CPI to find the total number of clock cycles:
CPU clock cyclesP1 = Σ( CPIi × Instruction counti ) where i = A .. C
= 1×104×0.3 + 2×104×0.3 + 3×104×0.4 = 21,000 cycles
CPU clock cyclesP2 = Σ( CPIi × Instruction counti ) where i = A .. C
= 2×104×0.3 + 2×104×0.3 + 2×104×0.4 = 20,000 cycles