typical cpu clock rate = 2.4 GHz = 2.4 * 10^9 Hz = 2.4E9 Hz
2.4E9 CPU clock cycles/ 1 sec = 2.4E9 clock cycles / 1E9 ns
Typical operation timings src
- fetch RAM is measured in nano seconds
- fetch disk is measured in milliseconds
lesson: if performance is critical use an in-memory store like redis
1 s = 1e9 ns
Operation | Time (ns) |
---|---|
execute typical instruction | 1 ns |
fetch(L1) | 0.5 ns |
branch misprediction | 5 ns |
fetch L2 | 7 ns |
mutex (un)lock | 25 ns |
fetch main memory | 100 ns |
send 2K bytes over 1Gbps network | 20,000 ns |
read 1MB sequentially from memory | 250,000 ns (.25 ms) |
fetch from new disk location | 8,000,000 ns (8 ms) |
typical game frame @ 60 fps | 16 ms |
send packet from US to Europe and back | 150,000,000 ns ( 150 ms ) |
Example Calculations
2.4 billion clock cycles / sec = 2,400,000,000 cycles / sec = 2.4 clock cycles / ns
clock cycles to execute typical instruction:
1 ns * 2.4 clock cycles /ns = 2.4 cpu cycles
C = cpu_cyle
Operation | Clock cycles |
---|---|
fetch L1 | 0.5 ns * 2.4 cycles/ns = 1.2 cpu cycles |
branch misprediction | 7 ns * 2.4 cycles/ns = 15.4 cpu cycles |
fetch from main memory | 100 ns * 2.4 cycles/ns = 240 cpu cycles |
see: https://stackoverflow.com/questions/1371400/how-much-faster-is-the-memory-usually-than-the-disk