Memory location matters for performance
If you’re writing high-performance code, what matters is how many CPU instructions you run.
Right?
That’s what I learned long ago in school, anyway, when I took algorithms and data structures classes.
The basic assumption was that reading or writing to memory took a small, constant amount of time, and so you could focus on how many operations were being done.
This was so fundamental to how we were taught that we didn’t even have to write real code: pseudo-code was sufficient.
Unfortunately, this is not how a CPU works in the real world.
In the real world, access to memory is vastly slower than CPU instructions, and all those O(N)
measurements that just focus on CPU operations are insufficient to tell you what real-world performance