Cache Sizes with CPUID on Intel CPU's
blog.melkerlitsgard.se
blog.melkerlitsgard.se
Basically on x86 CPUs you can use the cpuid instruction to get information about the CPU and the cache: http://www.sandpile.org/x86/cpuid.htm
The code in the first snippet uses a compiler intrinsic to execute this instruction and calculates the cache size from the result. In the second snippet the assembler code is written by hand instead.
It's not that I thought that this information was difficult to look up, rather it seemed very odd information to be missing from a link that was submitted as useful/interesting.
I agree that the example isn't very well tested - the author probably pulled it out of some existing code and wasn't very careful.