Your Equation

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

Solve for
s
billion
0.01100
0.35
GHz
0.55
  • 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.

CPU time (s) current value 0.5 s
NinstInstructions executedKey driver
0.00550
fclkClock rate
0.33
CPICycles per instruction
0.11.67
  • 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

VariableTypical rangeLowest resultHighest resultSwing (s)Local stepChange in result
Ninst Instructions executed0.01 to 100 billion0.0055049.99+10%+10 %
fclk Clock rate0.5 to 5 GHz0.332.7+10%−9.09 %
CPI Cycles per instruction0.3 to 5 0.11.6671.567+10%+10 %

Sweep of Clock rate

Clock rate (GHz)CPU time (s)
0.53
1.0631.412
1.6250.9231
2.1880.6857
2.750.5455
3.3130.4528
3.8750.3871
4.4380.338
50.3

Sweep one variable

CPU time (s)Hover, touch, or use the arrow keys on the chart
0.511.522.53 12345 Clock rate (GHz) now 0.5

Variables and how each one contributes

tCPU

CPU time

Result · s

What the equation gives you. Everything else feeds it.

Ninst

Instructions executed

billion · typical 0.01 to 100

Dynamic count of instructions the program executes. Directly proportional.

CPI

Cycles per instruction

· typical 0.3 to 5

Average clock cycles per executed instruction. Directly proportional; depends on the architecture and the program mix.

fclk

Clock rate

GHz · typical 0.5 to 5

Clock frequency. Inversely proportional.

Worked example with the values above

  1. Cycles needed: 1 × 10⁹ instructions × 1.5 CPI = 1.5 × 10⁹ cycles.
  2. Clock rate: 3 × 10⁹ cycles per second.
  3. 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

Related formulas

Practise this formula