C A Lecture-3
C A Lecture-3
Lecture-03
1
Chapter - 2
2
Why examining performance is
important?
• Hardware performance is often key to the
effectiveness of an entire system.
3
Why assessing the performance is
challenging?
• The scale and intricacy of modern software
systems, together with the wide range of
performance improvement techniques employed
by hardware designers have made performance
assessment much more difficult.
5
Throughput and Response Time
6
Continuation
1
PerformanceX =
Execution timeX
Performance of X is greater than the performance
of Y
X is faster than Y
7
Continuation
PerformanceX
= n
PerformanceY
8
Example
If machine A runs a program in 10 seconds
and machine B runs the same program in 15
seconds, how faster is A than B?
9
Solution
PerformanceA
=n
PerformanceB
Execution timeB
=n
Execution timeA
15
= 1.5
10 than
– A is 1.5 times faster
B
10
Continuation
PerformanceA
=n
PerformanceB
PerformanceA
PerformanceB =
n
11
Measuring Performance
13
Continuation
User CPU time
CPU time
System CPU time
• User CPU time – the CPU time spent in
the program
Execution Time
CPU time
15
Continuation
• Example:
• Unix time command –
• 90.7u 12.9s 2:39 65%
90.7 + 12.9
= 0.65
16
159
Continuation
17
Continuation
• Clock cycle – Almost all computers are
constructed using a clock that
determines when events take place. These
discrete time intervals are called clock cycles
(ticks / clock ticks / clock periods / clocks /
cycles).
18
Relating the Metrics
20
Improving Performance (Cont.)
CPU clock cycleA
CPU timeA =
Clock rateA
CPU clock cycleA
10 Seconds =
400 × 106 cycles/sec
CPU clock cycleA = 10 seconds × 400 × 106 cycles/sec
= 4000 × 106 cycles
CPU clock cycleB
CPU timeB =
Clock rateB
1.2 × CPU clock cycleA
CPU timeB =
Clock rateB
21
Improving Performance (Cont.)
1.2 × 4000 × 106 cycles
6 seconds =
Clock rateB
1.2 × 4000 × 106 cycles
Clock rateB =
6 seconds
= 800 MHz
22
Example
Our favourite program runs in 10 seconds on computer A,
which has a 2 GHz clock. We are trying to help a computer
designer build a computer, B, which will run this program in 6
seconds. The designer has determined that a substantial
increase in the clock rate is possible, but this increase will affect
the rest of the CPU design, causing computer B to require 1.2
times as many clock cycles as computer A for this program.
What clock rate should we tell the designer to target?
23
24
Hardware Software Interface
26
Continuation
Let the number of instructions of the program be I
CPU clock cyclesA = I × 2.0
CPU clock cyclesB = I × 1.2
CPU timeA = CPU clock cyclesA × Clock cycle timeA
= I × 2.0 × 1 ns = 2I ns
CPU timeB = I × 1.2 × 2 ns = 2.4I ns
28
Continuation
29
Comparing Code Segments
• Example
– The hardware designer supplied:
Instruction Class CPI for this class
A 1
B 2
C 3
• Sequence 1 executes 2 + 1 + 2 = 5
instructions.
• Sequence 2 executes 4 + 1 + 1 = 6
instructions.
• So sequence 2 executes most instructions.
31
Solution
• CPU clock cycles1 = (2×1) + (1×2)
+ (2×3) = 2 + 2 + 6 = 10 cycles
32
Solution
CPU clock cycles1 10
CPI1 = = = 2
Instruction count1 5
33
Example
34
Processor Clock Rate CPI
P1 4GHz 1.25
P2 3GHz 0.75
Here,
CPU execution time , p1= (CPI * Instructions) / clock rate
= (1.25* 10^6)/ (4*10^9)
35
Performance p1 : performance p2 =
((0.75*10^6)/ (3*10^9) ) / ((1.25* 10^6)/ (4*10^9) )
= 0.8
36
MIPS (Millions instructions per second)
A measurement of program
execution speed based on the
number of millions of
instructions.
Limitations of MIPS:
38
39
40
Amdahl’s Law