Re: Computing cpu's clock in cycles per second

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

 




On 09/27/2010 07:34 AM, Wade Hampton wrote:
> 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
Thank you very much Wade.
I confirm that using rdtsc, the delta in tsc values, divided by 60 
(using nanosleep)
is  798283074.9833333333 ticks per second, which is almost iddentical
to what is reported by cpuinfo:
cpu MHz        : 798.244

No matter what the load factor on the machine, even when the load 
reached 5 or  6,
it is the same value.
Well, that's what you get for buying a laptop from a crappy manufacturer
that has put in it a fixed unprogrammable clock (oscillator), and put in a
lame BIOS that provides no hooks for setting C2 C3 ...etc.
I will certainly steer friends and family away from this manufacturer.


-- 
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