OiO.lk Blog C# Messuring performance hits between cache levels seems strange
C#

Messuring performance hits between cache levels seems strange


I have got intel core i7 12700k which says my l1 is 80k per core, l2 12 shared and l3 25 shared as well.

This is a simple program to sum up numbers:


void test(uint32_t count, uint32_t* arr)
{
    uint32_t sum = 0;
    for (uint32_t i = 0; i < count; ++i)
    {
        sum += arr[i];
    }
}

I try to double the input until i can’t, ex:
array[5]
array[10]
array[20]
array[40]
... ... ...
array[10m]
etc

so that i can see when the data from the array can’t fit into l1, l2, l3, ram, hoping to see performance drops but i don’t.

It seems like when i double the size, time to complete doubles the time. That is it.

Correct me if i am wrong but, at some point when i doubling the elements count in the array, it should give the time results different from just doubling, but tripling or even more when the array can’t fit into any caches but ram.
But didn’t happen. It just keeps going linearly.

I have tried different compilers like MSVS and clang.
I mesure time in ms using default C++ std::chrono.



You need to sign in to view this answers

Exit mobile version