• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Strategy for Measuring L1/L2 Cache Size

S0me1X

Golden Member
I'm just curious how to measure the size of L1 and L2 cache with simple benchmarks (something that I can do in C would be best).
 
A simple, crude way to do it:
int i, j;
void *foo;
while(1)
{
foo = malloc(1024*i);
for (k=0; k<10; k++)
{
for (j=0; j<i*1024; j++)
{
foo[j] = 0;
}
}
}

Add some timing code, and when you notice the first major performance drop, you passed the L1 size, and at the second major drop, you passed the L2 size. You could also just use linpack.
 
Back
Top