With a little bit of help from assembler, we can find the exact CPU cycle count. This can be very much helpful to find the execution time of a program or function. The code to find the cpu cycle count is given below.
unsigned int LowWord = 0;
unsigned int HighWord = 0;
// Insert Real Time Stamp Counter opcodes
mov HighWord, edx
mov LowWord, eax
return ((__int64)(HighWord) << 32) + LowWord; } [/sourcecode] We can use the above function at the beginning and end of a program to get the no. of clock cycles it needed.