Profiling CPU cache in Linux
We can see how effectively cache is being used by using:
valgrind --tool=cachegrind ls
cachegrind is a tool for doing cache simulations and annotating your source line-by-line with the number of cache misses. In particular, it records:
L1 instruction cache reads and misses
L1 data cache reads and read misses, writes and write misses
L2 unified cache reads and read misses, writes and writes misses