This benchmark measures how long it takes to access data at different array sizes. When data fits in your CPU's cache, access is fast. When data exceeds cache size, the CPU must fetch from slower memory levels.
By watching where access times jump, you can identify your CPU's cache boundaries.
gcc -O2 architecture_analysis.c -o arch_analysis
./arch_analysis
gcc -O2 architecture_analysis.c -o arch_analysis
./arch_analysis
gcc -O2 architecture_analysis.c -o arch_analysis
./arch_analysis
The program will test array sizes from 4 KB to 64 MB and print access times in nanoseconds. Look for lines marked with <-- JUMP indicating a significant increase in access time.
Example output:
Array Size Elements Avg Access Time (ns)
---------- -------- --------------------
4 KB 1024 0.85
8 KB 2048 0.87
16 KB 4096 0.86
32 KB 8192 0.91
64 KB 16384 1.42 <-- JUMP
128 KB 32768 1.45
256 KB 65536 1.89 <-- JUMP
...
"gcc not found": Install gcc using your system's package manager or download MinGW (Windows).
Program runs too long: The benchmark takes 1-2 minutes to complete. Be patient.
No jumps visible: Your CPU's cache may be large enough that the test sizes don't exceed it, or the system is under heavy load. Close other applications and try again.