performancecpuperformancecountercpu-speed

Intructions vs cycles per second - what is actually measured in Hertz?


So I am going through some tutorials, and it seems they keep using "instructions" and "cycles" interchangeably, so now I am confused what is actually measured in Hertz (on the most basic level, without going into what the modern processors can do in parallel etc, trying to learn the basics here).

Say, the program is as follows: load two numbers, add them, store result. So there will be 4 cycles:

  1. load number A [fetch-decode-execute]
  2. load number B [fetch-decode-execute]
  3. add A and B [fetch-decode-execute]
  4. store result [fetch-decode-execute]

What is a cycle here, and what is an instruction?

There are 4 cycles, or 12 instructions, correct?

Say, it takes CPU 1 sec to run this program. What will be the CPU clock speed? 12 instructions/1 sec or 4 cycles/1 sec?


Solution

  • From helpful comments by @Nate Eldredge:

    "A fetch-decode-execute cycle is one instruction cycle, but three clock cycles.

    The clock speed measures the number of clock cycles per second."

    Thus, if the program is executed within 1 second, and it takes 12 clock cycles, the clock speed of that particular CPU is 12 Hz.