I'm trying to measure how long it takes to execute a function 'check()' using rdtsc as follows:
a = rdtsc();
check(pw);
b = rdtsc();
return (b-a);
However, I am receiving very small time differences, which I think is due to my compiler (using G++, on windows) optimising the code. As 'check()' does not affect any other part of the program, I think the compiler is ignoring this call altogether.
I have read about using something called asm volatile to tell the compiler not to optimise a certain section of code, but I cannot figure out how to implement it.
Any help on this?