KEMBAR78
Unit 2 Performance | PDF | Central Processing Unit | Office Equipment
0% found this document useful (0 votes)
36 views6 pages

Unit 2 Performance

The document discusses computer performance metrics, focusing on response time, throughput, and the relationship between execution time and performance. It introduces key concepts such as CPU execution time, clock cycles, and the Classic CPU Performance Equation, which relates instruction count, CPI, and clock cycle time. Additionally, it provides examples comparing the performance of different computers and code sequences based on these metrics.

Uploaded by

ritikachouhan823
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views6 pages

Unit 2 Performance

The document discusses computer performance metrics, focusing on response time, throughput, and the relationship between execution time and performance. It introduces key concepts such as CPU execution time, clock cycles, and the Classic CPU Performance Equation, which relates instruction count, CPI, and clock cycle time. Additionally, it provides examples comparing the performance of different computers and code sequences based on these metrics.

Uploaded by

ritikachouhan823
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Performance

Time is the measure of computer performance: the computer that performs the same amount of work
in the least time is the fastest. Program response time or execution time is measured in seconds per
program. Computers are often shared, however, and a processor may work on several programs
simultaneously. In such cases, the system may try to optimize throughput rather than attempt to
minimize the response time for one program. Hence, we often want to distinguish between the
response time and the time that the processor is working on our behalf.

Response time

 The total time required for the computer to complete a task, including disk accesses, memory
accesses, I/O activities, operating system overhead, CPU execution time, and so on.

Throughput

 Another measure of performance, it is the number of tasks completed per unit time.

Relative Performance
To maximize performance, we want to minimize response time or execution time for some task. Thus,
we can relate performance and execution time for a computer X:

1
Performance𝑋 =
Execution Time𝑋

This means that for two computers X and Y, if the performance of X is greater than the performance of
Y, we have

Performance𝑋 > Performance𝑌

1 1
>
Execution Time𝑋 Execution Time𝑌

Execution Time𝑌 > Execution Time𝑋

That is, the execution time on Y is longer than that on X, if X is faster than Y. In discussing a computer
design, we often want to relate the performance of two different computers quantitatively. We will use
the phrase “X is n times faster than Y” or equivalently “X is n times as fast as Y”. So we can write

Performance𝑋
=𝑛
Performance𝑌

If X is n times faster than Y, then the execution time on Y is n times longer than it is on X:

Performance𝑋 Execution Time𝑌


= =𝑛
Performance𝑌 Execution Time𝑋
If computer A runs a program in 10 seconds and computer B runs the same program in 15 seconds,
Prob. 1
how much faster is A than B?

We know that A is n times faster than B if

Performance𝐴 Execution Time𝐵


= =𝑛
Performance𝐵 Execution Time𝐴

Thus the performance ratio is

Performance𝐴 15
= = 1.5
Performance𝐵 10

and A is therefore 1.5 times faster than B.

Measuring Performance
CPU Execution Time or CPU Time

This is the actual time spend by the CPU for computing a task and does not include time spent waiting
for I/O or running other programs. CPU time can be further divided into two parts:

User CPU Time

 The CPU time spent in a program itself.

System CPU Time

 The CPU time spent in the operating system performing tasks on behalf of the program.

The term system performance is used to refer Response Time and CPU performance to refer User CPU
Time for unloaded system.

Clock Cycle

Almost all computers are constructed using a clock that determines when events take place in the
hardware. These discrete time intervals are called clock cycles (or ticks, clock ticks, clock periods,
clocks, cycles).

Clock Period

 Clock Period is the length of each clock cycle.

Designers refer to the length of a clock period as

 The time for a complete clock cycle (e.g., 250 picoseconds, or 250 ps).
 The clock rate (e.g., 4 gigahertz, or 4 GHz), which is the inverse of the clock period.

CPU Performance and Its Factors


A simple formula relates the clock cycles and clock cycle time to CPU time for a program:

CPU execution time = CPU clock cycles × Clock cycle time

Alternatively, because clock rate and clock cycle time are inverses,

CPU clock cycles


CPU execution time =
Clock Rate

This formula makes it clear that the hardware designer can improve performance by reducing the
number of clock cycles required for a program or the length of the clock cycle.

A 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
Prob. 2 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?

Let’s first find the number of clock cycles required for the program on A:
CPU Clock Cycles𝐴
CPU Time𝐴 =
𝐶𝑙𝑜𝑐𝑘 𝑅𝑎𝑡𝑒 𝐴
CPU Clock Cycles𝐴
10 𝑆𝑒𝑐. =
2 × 109 𝐶𝑦𝑐𝑙𝑒𝑠 𝑆𝑒𝑐.
CPU Clock Cycles𝐴 = 10 × 2 × 109 = 20 × 109 𝑐𝑦𝑐𝑙𝑒𝑠
CPU time for B can be found using this equation:
1.2 × CPU Clock Cycles𝐴
CPU Time𝐵 =
𝐶𝑙𝑜𝑐𝑘 𝑅𝑎𝑡𝑒 𝐵
1.2 × 20 × 109 𝑐𝑦𝑐𝑙𝑒𝑠
6 𝑠𝑒𝑐 =
𝐶𝑙𝑜𝑐𝑘 𝑅𝑎𝑡𝑒 𝐵

1.2 × 20 × 109 𝑐𝑦𝑐𝑙𝑒𝑠 0.2 × 20 × 109 𝑐𝑦𝑐𝑙𝑒𝑠


𝐶𝑙𝑜𝑐𝑘 𝑅𝑎𝑡𝑒 𝐵 = =
6 𝑠𝑒𝑐 𝑠𝑒𝑐
4 × 109 𝑐𝑦𝑐𝑙𝑒𝑠
𝐶𝑙𝑜𝑐𝑘 𝑅𝑎𝑡𝑒 𝐵 = = 4 𝐺𝐻𝑧
𝑠𝑒𝑐
To run the program in 6 seconds, B must have twice the clock rate of A.
Instruction Performance
The performance equations till know, not include any reference to the number of instructions needed
for the program. However, since the compiler clearly generated instructions to execute, and the
computer had to execute the instructions to run the program, the execution time must depend on the
number of instructions in a program. In other words response time or execution time is that it equals
the number of instructions executed multiplied by the average time per instruction. Therefore, the
number of clock cycles required for a program can be written as

𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠 = 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑓𝑜𝑟 𝑎 𝑝𝑟𝑜𝑔𝑟𝑎𝑚 × 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠 𝑝𝑒𝑟 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛

 The term clock cycles per instruction, which is the average number of clock cycles each
instruction takes to execute, is often abbreviated as CPI.
 Since different instructions may take different amounts of time depending on what they do, CPI
is an average of all the instructions executed in the program.
 CPI provides one way of comparing two different implementations of the same instruction set
architecture, since the number of instructions executed for a program will, of course, be the
same.

If we have two implementations of the same instruction set architecture. Computer A has a
clock cycle time of 250 ps and a CPI of 2.0 for some program, and computer B has a clock cycle
Prob. 3
time of 500 ps and a CPI of 1.2 for the same program. Which computer is faster for this
program and by how much?

We know that each computer executes the same number of instructions for the program; let’s
call this number I. First, find the number of processor clock cycles for each computer:
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠𝐴 = 𝐼 × 2.0
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠𝐵 = 𝐼 × 1.2
Now we can compute the CPU time for each computer:
𝐶𝑃𝑈 𝑡𝑖𝑚𝑒 𝐴 = 𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠𝐴 × 𝐶𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒
𝐶𝑃𝑈 𝑡𝑖𝑚𝑒 𝐴 = 𝐼 × 2 × 250𝑝𝑠 = 500 × 𝐼 𝑝𝑠
Likewise, for B:
𝐶𝑃𝑈 𝑡𝑖𝑚𝑒 𝐵 = 𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠𝐵 × 𝐶𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒
𝐶𝑃𝑈 𝑡𝑖𝑚𝑒 𝐵 = 𝐼 × 1.2 × 500 𝑝𝑠 = 600 × 𝐼 𝑝𝑠
Clearly, computer A is faster. The amount faster is given by the ratio of the execution times:
CPU Performance𝐴 Execution Time𝐵 600 × 𝐼 𝑝𝑠
= = = 1.2
CPU Performance𝐵 Execution Time𝐴 500 × 𝐼 𝑝𝑠
We can conclude that computer A is 1.2 times as fast as computer B for this program.
The Classic CPU Performance Equation
We can write the basic performance equation in terms of instruction count (the number of instructions
executed by the program), CPI, and clock cycle time and known as The Classic CPU Performance
Equation:

𝐶𝑃𝑈 𝑡𝑖𝑚𝑒 = 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑐𝑜𝑢𝑛𝑡 × 𝐶𝑃𝐼 × 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒 𝑡𝑖𝑚𝑒

or, since the clock rate is the inverse of clock cycle time:

𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝑐𝑜𝑢𝑛𝑡 × 𝐶𝑃𝐼


𝐶𝑃𝑈 𝑡𝑖𝑚𝑒 =
𝐶𝑙𝑜𝑐𝑘 𝑟𝑎𝑡𝑒

These formulas are particularly useful because they separate the three key factors that affect
performance. We can use these formulas to compare two different implementations or to evaluate a
design alternative if we know its impact on these three parameters.

We can see how these factors are combined to yield execution time measured in seconds per program:

𝑆𝑒𝑐𝑜𝑛𝑑𝑠 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 𝐶𝑙𝑜𝑐𝑘 𝐶𝑦𝑐𝑙𝑒𝑠 𝑆𝑒𝑐𝑜𝑛𝑑𝑠


𝑇𝑖𝑚𝑒 = = × ×
𝑃𝑟𝑜𝑔𝑟𝑎𝑚 𝑃𝑟𝑜𝑔𝑟𝑎𝑚 𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝐶𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒

A compiler designer is trying to decide between two code sequences for a particular computer.
Prob. 3
The hardware designers have supplied the following facts:

CPI for each instruction class

CPI A B C

1 2 3

For a particular high-level language statement, the compiler writer is considering two code
sequences that require the following instruction counts:

Instruction counts for each instruction class

Code
A B C
sequence

1 2 1 2

2 4 1 1

Which code sequence executes the most instructions? Which will be faster? What is the CPI for
each sequence?

Sequence 1 executes 2 + 1 + 2 = 5 instructions. Sequence 2 executes 4 + 1 + 1 = 6 instructions.


Therefore, sequence 1 executes fewer instructions.
We can use the equation for CPU clock cycles based on instruction count and CPI to find the
total number of clock cycles for each sequence:
𝑛

𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒 = 𝐶𝑃𝐼𝑖 × 𝐶𝑖


𝑖=1

This yields
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠1 = 2 × 1 + 1 × 2 + 2 × 3 = 2 + 2 + 6 = 10 𝑐𝑦𝑐𝑙𝑒𝑠
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠2 = 4 × 1 + 1 × 2 + 1 × 3 = 4 + 2 + 3 = 9 𝑐𝑦𝑐𝑙𝑒𝑠
So code sequence 2 is faster, even though it executes one extra instruction. Since code sequence 2
takes fewer overall clock cycles but has more instructions, it must have a lower CPI. The CPI values
can be computed by
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠
𝐶𝑃𝐼 =
𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠1 10
𝐶𝑃𝐼1 = = = 2.0
𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡1 5
𝐶𝑃𝑈 𝑐𝑙𝑜𝑐𝑘 𝑐𝑦𝑐𝑙𝑒𝑠2 9
𝐶𝑃𝐼2 = = = 1.5
𝐼𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛 𝑐𝑜𝑢𝑛𝑡2 6

Prob. 3
Suppose a program (or a program task) takes 1 billion instructions to execute on a processor
running at 2 GHz. Suppose also that 50% of the instructions execute in 3 clock cycles, 30%
execute in 4 clock cycles, and 20% execute in 5 clock cycles. What is the execution time for the
program or task?

* Do by yourself

You might also like