Skip to content

Instantly share code, notes, and snippets.

@tnn4
Last active October 11, 2023 19:03
Show Gist options
  • Save tnn4/cb4231933f71f491de7921d8639f354c to your computer and use it in GitHub Desktop.
Save tnn4/cb4231933f71f491de7921d8639f354c to your computer and use it in GitHub Desktop.
computer operation speeds cpu fps

CPU Speeds

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

Memory Access

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment