#if defined(__i386__)
static __inline__ unsigned long long rdtsc(void)
{
unsigned long long int x;
__asm__ volatile ("rdtsc" : "=A" (x));
return x;
}
#elif defined(__x86_64__)
static __inline__ unsigned long long rdtsc(void)
{
unsigned hi, lo;
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
}
#endif
int64_t getCpuFreq()
int64_t start1,start2;
start1 = rdtsc();
sleep(5);
start2 = rdtsc();
// asm volatile("" : : : "memory");
return (start2-start1)/5000;
}
int64_t timeUsed(){
start = rdtsc();
sleep(xx);
end = rdtsc();
return (end-start)*1000/cpuFreq;
}