Library / Computer / CMP-01
Computer
Processor execution time
How long a program takes from instruction count, CPI and clock rate.
- Ref
- CMP-01
- Rev
- v1
- Field
- Computer
- Result
- tCPU [s]
Ninst the dynamic instruction count, CPI the average clock cycles per executed instruction and fclk the clock rate. Weight each instruction class’s CPI by its share of executed instructions.
Run time is the number of instructions, times how many clock ticks each one needs on average, divided by how many ticks happen per second.
Calculator
- Instructions per second2,000 MIPS
- Clock period0.3333 ns
What drives the result
Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.
- Three levers: fewer instructions (compiler, algorithm), lower CPI (architecture) or a faster clock. They multiply.
- A faster clock does not help if CPI rises with it, for instance when memory cannot keep up.
- Comparing processors by clock speed alone is misleading; compare execution time on the same program.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing (s) | Local step | Change in result |
|---|---|---|---|---|---|---|
| Ninst Instructions executed | 0.01 to 100 billion | 0.005 | 50 | 49.99 | +10% | +10 % |
| fclk Clock rate | 0.5 to 5 GHz | 0.3 | 3 | 2.7 | +10% | −9.09 % |
| CPI Cycles per instruction | 0.3 to 5 | 0.1 | 1.667 | 1.567 | +10% | +10 % |
Sweep of Clock rate
| Clock rate (GHz) | CPU time (s) |
|---|---|
| 0.5 | 3 |
| 1.063 | 1.412 |
| 1.625 | 0.9231 |
| 2.188 | 0.6857 |
| 2.75 | 0.5455 |
| 3.313 | 0.4528 |
| 3.875 | 0.3871 |
| 4.438 | 0.338 |
| 5 | 0.3 |
Sweep one variable
Variables and how each one contributes
CPU time
What the equation gives you. Everything else feeds it.
Instructions executed
Dynamic count of instructions the program executes. Directly proportional.
Cycles per instruction
Average clock cycles per executed instruction. Directly proportional; depends on the architecture and the program mix.
Clock rate
Clock frequency. Inversely proportional.
Worked example with the values above
- Cycles needed: 1 × 10⁹ instructions × 1.5 CPI = 1.5 × 10⁹ cycles.
- Clock rate: 3 × 10⁹ cycles per second.
- Time = 0.5 s.
Assumptions and limits
- Dynamic instruction count, not program size.
- CPI averaged over the whole run, weighted by instruction mix.
- Single core, fixed clock rate.
Common mistakes
- Using static program size as the instruction count.
- Mixing GHz with MHz.
- Reporting a clock rate where a latency is wanted.
Statistics and uncertainty
Measured run times vary from run to run by 1–5% from system noise; report the mean and spread of repeated runs. The three factors are multiplied, so their relative errors combine in quadrature.
Where it is used
- Comparing processors and compilers.
- Estimating timing margins in embedded and real-time systems.
- Choosing a processor for a sensor-processing task.
Maths you need
- Clock period: period = 1/frequency
- Averages: weighted CPI