CHAPTER 2 A
PERFORMANCE
1
PERFORMANCE
Execution Time is the time between
the start and completion of a task
Throughput: is the total amount of
work done in a given time
2
Performance
is
how gooda computer 1
E PERFORMANCE
EXECUTION TIME
X
• The performance of computer X is
inversely proportional to its
execution time.
• The smaller the execution time the
larger the performance.
3
Example problem:
A program takes 5 seconds to
execute on Computer X and
10 seconds to execute on
Computer Y.
(a) Which computer is better (faster)?
(b) Find the performance of computer
X and computer Y. Pets
Pr to
Py_y
Px 4
Solution:
(a) Computer X is better (faster) because
it executes the program in less time.
(b) Performance of Computer X
1
PERFORMANCE X
EXECUTION TIME X
Performance of Computer Y:
1
PERFORMANCEY
EXECUTION TIMEY
To 5
PERFORMANCE RATIO n:
PERFORMANCE X
n
PERFORMANCEY
Computer X is n times faster that
Computer Y. If n is smaller than 1
then Y is faster
If n is smaller than 1, divide the Performance of
Y over the Performance of X, get a number
greater than 1, and say that Computer Y is n
times faster that Computer X. 6
Ig 2 D compaterxiszt.me
than computer I
faster
1
PERFORMANCE EXECUTION TIME EXECUTION TIME
n
X
X Y
PERFORMANCE Y
1 EXECUTION TIME X
EXECUTION TIME Y
PERFORMANCE EXECUTION TIME
X
n Y
PERFORMANCE EXECUTION TIME
Y X
7
Example problem:
A program takes 10 seconds to
execute on Computer A and 15
seconds to execute on Computer B.
(a) Which computer is better (faster)? A
(b) Find the performance of computer A
and computer B.
É'D
(c) By how much is computer A faster or
slower than computer B? times
15
8
Solution:
(a) Computer A is better (faster) because
it executes the program in less time.
(b) Performance of Computer A:
1
PERFORMANCE A
EXECUTION TIME A
Performance of Computer B:
Is
1
PERFORMANCE B
EXECUTION TIME B
9
(c)
1
PERFORMANCE X EXECUTION TIME X
PERFORMANCEY 1
EXECUTION TIMEY
PERFORMANCE X EXECUTION TIMEY
15
PERFORMANCEY EXECUTION TIME X
Computer ______ is _____
1.5 times faster than
A
Computer ______
B
10
ELAPSED Time or RESPONSE Time or
WALL-CLOCK Time:
is the total time needed to complete a task.
Including:
• Disk accesses
• Memory accesses
• I/O activities
• Operating System overhead
• Time spent executing other programs
(multitasking) 11
Execution Time or i
iiiIiTi
M.IiIiIiiII
i.iTII idi.ii i
CPU Execution Time or
CPU Time:
is the time the CPU spends computing a
particular task (executing a particular
program)
• Not including time waiting for I/O or
running other programs
12
CPU_Execution_Time (of a program)
number_of_CPU_clock_cycles in a program Clock_cycle_time
1
number_of_CPU_clock_cycles in a program
Clock _ Rate
or
Execution_Time (of a program)
number_of_CPU_clock_cycles in a program T
1
number_of_CPU_clock_cycles in a program
f
Where T (or Clock cycle time) is the period of the CPU’s clock,
measured in seconds
and f (clock rate) is the frequency of the computer in Hz
T=1/f f=1/T 13
Example problem:
A program takes 10 seconds to
execute on Computer A (100Mhz). The
same program takes 6 seconds to
execute on Computer B. Computer B
requires 1.2 times as many clock cycles
as Computer A in order to execute the
program.
(a) Find the Clock Rate (frequency f) of
computer B.
14
Solution:
my
Exexution Time number of Ts T
Exexution Time number_of_CPU_clock_cycles T
1
Exexution Time number_of_CPU_clock_cycles
f
For Computer A
ICCA
TIME
number_of_CPU_clock_cycles ??
cca 15
1 2
CCB CCA x
CCB 1.2
For Computer B :
1
6 number_of_CPU_clock_cycles
Eps f
109
6 1 2
4
40.2Gt 16
For Computer B :
1
6 number_of_CPU_clock_cycles
f
6 1.2 1000 10
6 1
f
f ???
17
NOTE:
Instructions do NOT take the same
number of CPU clock cycles to be
executed.
18
number_of_CPU_clock_cyclesin a program
number_of_Instructions in a program
Average_number_of CPU_Clock_Cycles_needed_per Instruction
number_of_CPU_clock_cyclesin a program I CPI
I: Total Number of instructions in a program
CPI: Cycles Per Instruction (Average
number of Cycles needed for one
Instruction to execute
numbers of ticks per instruction 19
Execution_Time (of a program)
I CPI Clock_cycle_time
1
I CPI
Clock _ Rate
or
Execution Time I CPI T
1
Execution Time I CPI
f
20
Example problem:
Computer A has a clock Cycle Time =
10 nsec and runs a specific program
with CPI=2. 10nsec
Ta
Computer B has a clock Cycle Time =
20 nsec and runs the same program
with CPI=1.2 20nsec
a
To
(Assume both computers use the same compiler, therefore
they have the same number of assembly instructions)
Fa Fis
(a) Which computer is faster and by how
much? 21
Eis
Solution:ÉIÉpe Z
comp h
PERFORMANCE A EXECUTION TIME B
n is 7.2 times
PERFORMANCE B EXECUTION TIME A faster
EXECUTION TIME B
EXECUTION TIME A
EXECUTION TIME B
EXECUTION TIME A
A
Computer ___ is ___
B
1.2 times faster than Computer ___
CPI: Cycles Per Instruction (Average number of
Cycles needed, to execute 1 Instruction) 22
Example problem:
Assume that a Computer has three categories of
instructions: category A, B and C.
Category A instructions take 5 CPU clock cycles to
execute. CP 5
IA
Category B instructions take 8 CPU clock cycles to
execute.
CPI 8
Category C instructions take 4 CPU clock cycles to
execute. CPI 4
A program has 10 instructions from category A,
20 instructions from category B and
40 instructions from category C. Find the CPI.
23
Average number of Cycles needed Per
Instruction = CPI
CPI = (all clock cycles needed to execute the
program) / (total number of instructions in the
program)
= I 70 FA lo XCPFa 50
CPI 5.28078
3
24
When a program has
• n categories (classes) of instructions
• Ci number of instructions in every
category i
• CPIi being the average number of
clock cycles needed for instructions
in category i, to be executed
25
The CPI for the whole program is
given by:
n n
C i CPI i C i CPI i
CPI i 1
n
Baggot i 1
I
C
i 1
i
26
Example problem:
The hardware designers of a Computer
have supplied the following facts for their
computer: There are three classes
(categories) of instructions
Instruction Class CPI for each Instruction Class
Class A 1
Class B 2
Class C 3
27
Two code sequences (programs) are
written for the same purpose (executing
the same job).
Number of Instructions in every Class
Code A B C
Sequence
1 2 1 2
2 4 1 1
I 5 CPI
7 1 CPI 10
28
D
6 CPI 9 CPI 2 1
2 54 1
Question:
(a) Which Code sequence executes
more instructions? 2 67
(b) Which Code sequence will be
executed faster? 2
(c) Find the CPI for the two Code
sequences (programs).
2 1.5
29
Solution:
(a) Which Code sequence executes
more instructions?
Code sequence 1 executes (2+1+2) =
5 instructions
Code sequence 2 executes (4+1+1) =
6 instructions
Conclusion: Code sequence 2
executes more instructions
30
Solution:
(b) Which Code sequence will be
executed faster?
Total Number of CPU Clock cycles needed
to execute Code sequence 1=
= 2
Total Number of CPU Clock cycles needed
to execute Code sequence 2=
= 1.5
2 will
Conclusion: Code sequence ____
execute faster 31
Solution:
(c) Find the CPI for the two Code
sequences (programs).
n n
C CPI C CPI
i i i i
CPI _ of _ Code _ Seq _ 1 i 1
n
i 1
I
C
i 1
i
32
n categories (classes) of instructions
Ci number of instructions in every category i
CPIi being the average number of clock
cycles needed for instructions in category i,
to be executed
n n
C CPIi i C CPI
i i
CPI _ of _ Code _ Seq _ 2 i 1
n
i 1
I
C
i 1
i
33