0

This is the code I am using in C to convert RDTSC clock ticks to time in usec. Assembly code to read the TSC. To covert RDTSC clock ticks to time, need to divide it with CPU clock frequency in GHz. CPU Frequency = 0.963 is in GHz. I don't know where am I wrong in the conversion?

static inline uint64_t RDTSC() { unsigned int hi, lo; __asm__ volatile("rdtsc" : "=a" (lo), "=d" (hi)); return ((uint64_t)hi << 32) | lo; } start = RDTSC(); end = RDTSC(); printf("\n-%.4f us-",((double)(end-start)/(double)0.963)/1000); 
4
  • 3
    What value do you get? And what do you get for end-start? Commented Aug 22, 2021 at 22:08
  • Divide by 0.963e9? Commented Aug 23, 2021 at 2:49
  • Duplicate: stackoverflow.com/questions/42189976/… Commented Aug 23, 2021 at 4:46
  • Does this answer your question? Calculate system time using rdtsc Commented Aug 23, 2021 at 4:46

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.