On my machine Time A and Time B swap depending on whether A
is
defined or not (which changes the order in which the two calloc
s are called).
I
You should also test using malloc
instead of calloc
. One thing that calloc
does is to fill the allocated memory with zeros.
I believe in your case that when you calloc
arr1 last and then assign to it, it is already faulted into cache memory, since it was the last one allocated and zero-filled. When you calloc
arr1 first and arr2 second, then the zero-fill of arr2 pushes arr1 out of cache.