Possible Duplicate:
Getting cpu cycles using RDTSC - why does the value of RDTSC always increase?
Get CPU cycle count?
I want to write C++ code which analyzes sorting algorithms, and I need to know how many processor cycles it takes to sort an array.
Any suggestions on how to do that?
I found this code here:
uint64_t rdtsc(){
unsigned int lo,hi;
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
return ((uint64_t)hi << 32) | lo;
}
I understand it is inline assembly, could someone explain how it works and how to use it?
I run Linux. My computer is dual core, does that makes a difference?