Learning Outcomes
SLO | After this lecture you can… | CLO | Bloom |
|---|---|---|---|
SLO 4.1 | Differentiate execution time, throughput and CPU time, and state how many times faster one computer is. | CLO2 | C2 Understand |
SLO 4.2 | Apply the CPU performance equation to compare computers and find average CPI from an instruction mix. | CLO2 | C3 Apply |
SLO 4.3 | Identify which design decisions change instruction count, CPI and clock rate. | CLO2 | C2 Understand |
§1 What Is Performance?
§1.1 Execution time and throughput
Slide L04-S06
Execution time (response time) | Throughput (bandwidth) | |
|---|---|---|
Meaning | Time to finish one task, start to end | Total work done per unit time |
Who cares | A single user | A data-center or system manager |
NADRA office example | A faster clerk serves you sooner | Opening more counters serves more people per hour |
In this lecture performance means the inverse of execution time: Performance = 1 / Execution time.
§1.2 How many times faster?
Slide L04-S07
X is n times faster than Y: n = Time(Y) / Time(X) = Performance(X) / Performance(Y) |
Always put the slower (larger) time on top so that n is greater than 1. Say '1.5 times faster', not '50% faster'.
§1.3 Elapsed time and CPU time
Slide L04-S08
Elapsed (wall-clock) time includes everything: disk and network waits, other programs and the operating system. CPU time is only the time the processor spends on this program: user CPU time (in the program) plus system CPU time (in the operating system on its behalf). On Linux the time command shows all three, for example:
real 0m10.200s <- elapsed time |
The CPU performance equation (§2) predicts CPU time, not elapsed time.
§2 The CPU Performance Equation
§2.1 The equation
Slide L04-S10
CPU time = Instruction count x CPI x Clock cycle time = IC x CPI / Clock rate |
Term | Meaning | Example |
|---|---|---|
IC | Number of instructions executed (a loop repeats its lines) | 28 instructions in Practical 2 Task 2 |
CPI | Average clock cycles per instruction | 1.5 |
Clock cycle time | 1 / clock rate | 2 GHz → 0.5 ns |
§2.2 Worked example 1: faster clock, slower computer
Slide L04-S11
Same program, IC = 10^9 on both machines. |
§2.3 Average CPI from an instruction mix
Slide L04-S12
Different instruction classes need different numbers of cycles. Average CPI = Σ (fraction of instructions in class i × CPI of class i).
Class | Fraction | CPI | Fraction × CPI |
|---|---|---|---|
ALU | 50% | 1 | 0.5 |
Load | 20% | 5 | 1.0 |
Store | 10% | 3 | 0.3 |
Branch | 20% | 2 | 0.4 |
Average CPI | 2.2 |
Loads are only 20% of the instructions but cause 1.0 / 2.2 = 45% of the cycles, so they are the place to improve.
§2.4 Worked example 2: faster loads
Slide L04-S13
Loads improved from CPI 5 to CPI 2 (same IC and clock): |
§3 What Changes IC, CPI and Clock?
§3.1 Who affects each term
Slide L04-S15
Decision | IC | CPI | Clock rate |
|---|---|---|---|
Algorithm / program | Yes | Yes | |
Compiler | Yes | Yes | |
Instruction set (ISA) | Yes | Yes | Yes |
Organization (pipeline, cache) | Yes | Yes | |
Hardware technology | Yes |
§3.2 Worked example 3: more instructions, less time
Slide L04-S16
A (CPI 1) | B (CPI 2) | C (CPI 3) | IC | Cycles | CPI | |
|---|---|---|---|---|---|---|
Sequence 1 | 2 | 1 | 2 | 5 | 10 | 2.0 |
Sequence 2 | 4 | 1 | 1 | 6 | 9 | 1.5 |
Sequence 2 runs more instructions but needs fewer cycles, so it is faster. Neither IC alone nor CPI alone measures performance - use CPU time.
§3.3 Reporting results
Slide L04-S17
A result must be reproducible: someone else must be able to repeat it. Report the hardware (processor, clock, cache, memory), the software (operating system, compiler, version, optimization flags such as -O2), the program and its input size, and how many runs were made and how they were combined. 'My program runs in 2 seconds' means nothing without these details.
§4 Common Mistakes
Slide L04-S19
Wrong idea | Correct idea |
|---|---|
The higher-GHz computer is faster. | Time = IC × CPI / clock rate; a lower CPI can beat a higher clock. |
IC = number of lines in the program. | IC = number of instructions executed; loops repeat lines. |
Fewer instructions always means faster. | Fewer instructions can need more cycles. |
'Y is 1.5 times faster' means Time(Y)/Time(X) = 1.5. | n = Time(slower) / Time(faster) = Time(X) / Time(Y). |
Word Bank
Word | Simple meaning | Real-world example |
|---|---|---|
Execution / response time | Time to finish one task | Time for your NADRA token to be served |
Throughput | Work done per unit time | People served per hour at the office |
Elapsed (wall-clock) time | Total time including waiting | Bus journey including stops |
CPU time | Time the processor works on this program | Time the bus is actually driving |
Instruction count (IC) | Instructions executed | Steps walked |
CPI | Average clock cycles per instruction | Seconds per step |
Clock rate | Clock cycles per second (Hz) | Beats per minute of a drum |
Instruction mix | Share of each kind of instruction | Share of tea, biscuits and samosas sold |
Reproducibility | Others can repeat the result | A recipe that works in every kitchen |
Self-Check Questions
- Define performance. A program takes 12 s on X and 8 s on Y: how many times faster is Y? (§1.2)
- What is the difference between elapsed time and CPU time? (§1.3)
- Write the CPU performance equation and give the unit of each term. (§2.1)
- IC = 5 × 10⁹, CPI = 1.6, clock = 4 GHz. Find the CPU time. (§2.1)
- Why can a 2 GHz computer beat a 3 GHz computer? (§2.2)
- Mix: ALU 60% (CPI 1), memory 30% (CPI 4), branch 10% (CPI 3). Find average CPI. (§2.3)
- Which terms does a better compiler change? A smaller transistor process? (§3.1)
- Explain with an example why fewer instructions is not always faster. (§3.2)
- List four things you must report with a performance result. (§3.3)
Answers: 1.5 times; 2.0 s; CPI = 2.1; compiler: IC and CPI; process: clock rate.
Further Reading
- Hennessy and Patterson (2012): Chapter 1, sections 1.8 (measuring, reporting and summarizing performance) and 1.9 (the processor performance equation).