What does clock frequency mean?
Understanding what GHz truly means, and why clock speed is not the only criterion for measuring CPU performance.
Life analogy: metronome
Imagine a metronome—a tool musicians use to practice rhythm. Set it to 120 beats per minute, and it ticks twice every second.
The number of beats per second of a metronome is just like the CPU's clock frequency.On each beat, the musician plays a note; in each clock cycle, the CPU may also execute one instruction. The faster the metronome ticks, the faster the playing; similarly, the higher the CPU frequency, the more "actions" it completes per unit time.
But there is a key limitation: if you set the metronome too fast—say, 600 beats per minute—the player will fail to keep up, hit wrong notes, or even fall into complete chaos. The CPU is the same:Frequency cannot be increased indefinitely, when the frequency is high enough, it encounters physical limits (power consumption and heat dissipation), which is exactly what this lecture will explore in depth.
Definitions of Hz and GHz
Hz (Hertz)It is the International System of Units (SI) unit for frequency, indicating how many times a periodic event occurs per second. This unit is named after German physicist Heinrich Hertz, who first experimentally confirmed the existence of electromagnetic waves in 1888.
The unit conversion relationship is as follows:
1 Hz = 1 cycle per second
1 kHz (kilohertz) = 1,000 Hz = 10^3 Hz
1 MHz (megahertz) = 1,000,000 Hz = 10^6 Hz
1 GHz (gigahertz) = 1,000,000,000 Hz = 10^9 Hz
Modern desktop CPUs typically run between 3 GHz and 5 GHz, meaning the clock signal oscillates 3 to 5 billion times per second. For an intuitive comparison: a human heartbeat is about 1-2 Hz, a hummingbird's wing flaps at about 50 Hz, and your phone's processor is running at about 3 GHz.
Relationship between clock cycle and frequency
The clock period is the time required for the clock signal to complete one full oscillation (from high level to low level and back to high level, or vice versa). Its relationship with frequency is very simple:
Clock period T = 1 / frequency f
For example, a 4 GHz CPU has a clock period T = 1/4,000,000,000 = 0.25 nanoseconds (ns). In this extremely short 0.25 ns, the CPU completes one basic operation step (such as one stage of instruction fetch, decode, or execute).
In a vacuum, light can travel only about 30 centimeters in 1 nanosecond—that is, in a single clock cycle (0.25 ns) of a 4 GHz CPU, light can travel only about 7.5 centimeters. This means signal transmission delay within the chip has become a limiting factor that cannot be ignored.
Frequency comparison of different clock sources
| Clock source/processor | frequency | Clock cycle | Era / Typical application |
|---|---|---|---|
| Quartz crystal oscillator | 32.768 kHz | Approximately 30.5 microseconds | Electronic watches, RTC real-time clock |
| Intel 4004 (the first commercial microprocessor) | 740 kHz | Approximately 1.35 microseconds | 1971 |
| Intel 8086(IBM PC) | 5-10 MHz | 100-200 nanoseconds | 1978 |
| Intel 80486 | 25-100 MHz | 10-40 nanoseconds | 1989 |
| Intel Pentium series | 60-300 MHz | 3.3-16.7 nanoseconds | 1993-1999 |
| Intel Pentium 4 (NetBurst architecture) | 1.3-3.8 GHz | 0.26-0.77 nanoseconds | 2000-2005 |
| Modern desktop processors (Core i9 / Ryzen 9) | 3-5.7 GHz | 0.18-0.33 nanoseconds | current |
| Modern mobile processors (Apple M series, etc.) | 2-4 GHz | 0.25-0.5 nanoseconds | current |
From the table above, CPU frequency increased by more than a thousand times in 25 years. But since the Pentium 4 era, frequency growth has slowed significantly—behind this are the power wall and the frequency wall.
Why clock speed is not the only criterion for measuring performance
4.1 IPC: Instructions per Cycle
IPC(Instructions Per Cycle)It is a core indicator for measuring CPU architecture efficiency, indicating how many instructions the CPU can execute on average per clock cycle.
Overall performance can be approximately described by the following formula:
Performance = Clock speed x IPC
For example: CPU A has a clock speed of 4 GHz and an IPC of 2, so it executes 4 billion x 2 = 8 billion instructions per second. CPU B has a clock speed of 3 GHz and an IPC of 4, so it executes 3 billion x 4 = 12 billion instructions per second. Although B's clock speed is 25% lower, because its IPC is twice as high, its actual performance is 50% higher.
This explains whyApple M1/M2 with lower clock frequencies can match or surpass Intel/AMD processors with higher clock frequencies in single-core performance.— their IPC is very high.
4.2 Multiple factors affecting performance
| Influencing factors | Description | Impact on actual performance |
|---|---|---|
| Clock frequency (main frequency) | Number of clock cycles per second, in Hz | Directly correlated, but constrained by physical limits |
| IPC (Instructions per Cycle) | Core metric of architectural efficiency | extremely high |
| Pipeline depth | Splits instruction execution into multi-stage parallel processing | High, but costly when branch prediction fails |
| Superscalar and out-of-order execution | Issue multiple instructions per cycle, execute out of program order | extremely high |
| Cache size and hierarchy | Capacity, speed, and hit rate of L1/L2/L3 caches | extremely high |
| Branch predictor | Guesses the direction of branch instructions in advance | High, a misprediction costs 10-20 cycles |
| Core count | Ability to process in parallel across multiple cores | Depends on whether the program is sufficiently multi-threaded |
| Process technology | Transistor size, such as 5nm, 3nm | Indirectly affects power consumption, frequency ceiling, and transistor density |
| Memory bandwidth and latency | Data transfer speed between the CPU and main memory | High, often becomes the bottleneck ("memory wall") |
4.3 Power wall and frequency wall
In the early 2000s, Intel drew up a roadmap predicting that CPU frequency would reach 10 GHz by 2010. But in reality, frequency hit a ceiling around 4-5 GHz, which is called the frequency wall."Frequency Wall"。
The root cause lies inPower WallThe approximate dynamic power consumption formula for CMOS circuits is: P = C x V^2 x f, where C is the capacitive load, V is the operating voltage, and f is the frequency. Increasing frequency requires simultaneously increasing voltage (otherwise transistors cannot complete state flipping in time), and power consumption is proportional to the square of voltage—this means the cost of increasing frequency is a sharp rise in power consumption.
When a chip's power consumption reaches 100-150W, conventional cooling methods (air cooling, water cooling) become very difficult. Increasing frequency further will cause the chip to overheat and be damaged. This is why the power wall limits the frequency wall.
For this reason, modern CPU design no longer simply pursues high clock speed, but instead turns to multi-core, higher IPC, optimized power efficiency, and other directions.
When buying a CPU, don't just look at the clock frequency (GHz). Two CPUs both at 3.5 GHz can differ by more than double in actual performance due to differences in architecture, IPC, cache, process node, and other factors. The most reliable way to evaluate CPU performance is to look at benchmark results from real-world application scenarios.
Interactive demo
Drag the slider below to change the frequency and watch the green square blink at the set frequency. When you adjust the frequency to 30 Hz, the square appears almost constantly lit—this is the persistence of vision effect of the human eye. A real CPU runs at the GHz level, far beyond human perception.
CPU clock frequency visualization (example demo)
Tip: 1 Hz = blinking once per second. The human eye can roughly distinguish flicker below 20-30 Hz. But a real CPU runs at the GHz level—billions of times per second, completely imperceptible to the naked eye. This demo helps you intuitively understand the core concept that "frequency = number of actions per second".
Python code demonstration
The following Python code demonstrates how to calculate the time required to execute N instructions at different frequencies and IPC values. You can intuitively see the respective impact of clock speed and IPC on performance:
Example
def calc_execution_time(frequency_ghz, num_instructions, ipc=1.0):
"""
Calculate the time required to execute a specified number of instructions at a given frequency.
Parameters:
frequency_ghz: CPU main frequency, unit GHz
num_instructions: total number of instructions to execute
ipc: instructions per cycle (Instructions Per Cycle), default 1.0
Returns:
float: execution time, in seconds
"""
cycles_per_second = frequency_ghz * 1_000_000_000
instructions_per_second = cycles_per_second * ipc
return num_instructions / instructions_per_second
def format_time(seconds):
"""Format seconds into a human-readable string"""
if seconds >= 1:
return f"{seconds:.3f} seconds"
elif seconds >= 0.001:
return f{seconds * 1000:.3f} milliseconds
elif seconds >= 0.000001:
return f{seconds * 1000000:.3f} microseconds
else:
return f{seconds * 1e9:.3f} nanoseconds
def main():
NUM_INST = 1_000_000_000 # 1 Billion Instructions
print("=" * 58)
print(example clock frequency and CPU performance demonstration)
print("=" * 58)
print(f" Total executed instructions: {NUM_INST:,}")
print()
# Test different frequency and IPC combinations
frequencies = [1.0, 2.0, 3.0, 4.0, 5.0]
ipc_values = [1.0, 2.0]
header = f" {'Frequency(GHz)':>10}"
for ipc in ipc_values:
header += f| {'IPC=' + str(int(ipc)) + ' elapsed':>14}
print(header)
print(" " + "-" * (len(header) - 2))
for f in frequencies:
row = f" {f:>10.1f}"
for ipc in ipc_values:
t = calc_execution_time(f, NUM_INST, ipc)
row += f" | {format_time(t):>14}"
print(row)
# Key Comparison: Low Clock Speed + High IPC vs High Clock Speed + Low IPC
print()
print(=== Key Comparison: Architecture vs Clock Speed ===)
t_a = calc_execution_time(3.0, NUM_INST, ipc=2.0)
t_b = calc_execution_time(5.0, NUM_INST, ipc=1.0)
print(f" CPU A (3.0 GHz, IPC=2): {format_time(t_a)}")
print(f" CPU B (5.0 GHz, IPC=1): {format_time(t_b)}")
if t_a < t_b:
speedup = t_b / t_a
print(f" 结论: Low频High IPC 胜出!CPU A Compare CPU B Fast {speedup:.2f}x")
else:
print(fConclusion: High frequency wins, but the gap is much smaller than the frequency ratio.)
# Impact of doubling frequency on execution time
print()
print(" === Frequency doubling test ===")
for base_freq in [1.0, 2.0]:
t1 = calc_execution_time(base_freq, NUM_INST, ipc=1.0)
t2 = calc_execution_time(base_freq * 2, NUM_INST, ipc=1.0)
print(f" {base_freq} GHz -> {base_freq*2} GHz: "
f"{format_time(t1)} -> {format_time(t2)} "
f(reduced to {t2/t1*100:.0f}%))
main()
Interactive demo: CSS animation frequency flasher
The demonstration below uses pure CSS@keyframesThe animation makes a block flash. Drag the slider to change the frequency, and the animation'sanimation-durationIt will adjust in real time.Compare the two demos above and below: the previous one uses JS to switch styles, while this one directly modifies the CSS animation speed—both implementations demonstrate the same core concept.
CSS Animation Frequency Flicker (example demo)
@keyframesAnimation implements blinking.animation-durationThe attribute is calculated in real time by JS based on the slider value: duration = 1 / frequency.
Frequency 0.5 Hz = blink every 2 seconds, frequency 10 Hz = blink 10 times per second.
When the frequency is high, the human eye cannot easily distinguish individual flicker cycles — but the CSS animation is still running precisely.