Re: Computing cpu's clock in cycles per second

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Did you look at using the RDTSC instruction to read the
cycle counter?

http://en.wikipedia.org/wiki/Time_Stamp_Counter

Sample this over an interval to get an estimate
of the clock frequency based on this counter.

__inline__ unsigned long long int rdtsc()
{
  unsigned long long int x;
  __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
  return(x);
}

I use gettimeofday() calls to check the wall-clock time,
usleep(n) to sleep for a long time (second or more),
and rdtsc to compute the cycles....  Seems to work
well.

Cheers,
--
Wade Hampton
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux