Re: a faster way to gettimeofday? rdtsc strangeness

From: Jamie Lokier (lk@tantalophile.demon.co.uk)
Date: Thu Mar 07 2002 - 20:57:01 EST


H. Peter Anvin wrote:
> I would like to see the error bars on your measurement.

I just ran it on my laptop 20 times in a row and it printed exactly the
same values every time:

        Kernel reports clock frequency: 366.601 MHz
        Measured clock frequency: 366.584 MHz

Well we need more precision than that. So here goes:

        Kernel reports clock frequency: 366.601000 MHz

        Measured clock frequency: 366.584116 MHz
        Measured clock frequency: 366.584071 MHz
        Measured clock frequency: 366.584108 MHz
        Measured clock frequency: 366.584116 MHz
        Measured clock frequency: 366.584090 MHz
        Measured clock frequency: 366.583968 MHz
        Measured clock frequency: 366.584069 MHz
        Measured clock frequency: 366.584106 MHz
        Measured clock frequency: 366.584172 MHz
        Measured clock frequency: 366.584093 MHz
        Measured clock frequency: 366.584077 MHz
        Measured clock frequency: 366.583939 MHz
        Measured clock frequency: 366.584083 MHz
        Measured clock frequency: 366.584118 MHz
        Measured clock frequency: 366.584062 MHz
        Measured clock frequency: 366.584085 MHz
        Measured clock frequency: 366.584066 MHz
        Measured clock frequency: 366.610417 MHz <- anomaly :-)
        Measured clock frequency: 366.584109 MHz
        Measured clock frequency: 366.584062 MHz
        Measured clock frequency: 366.582293 MHz
        Measured clock frequency: 366.584103 MHz
        Measured clock frequency: 366.584093 MHz
        Measured clock frequency: 366.584107 MHz
        Measured clock frequency: 366.584059 MHz
        Measured clock frequency: 366.583985 MHz
        Measured clock frequency: 366.584133 MHz
        Measured clock frequency: 366.584092 MHz
        Measured clock frequency: 366.584087 MHz
        Measured clock frequency: 366.555754 MHz <- another deviant!
        Measured clock frequency: 366.584044 MHz
        Measured clock frequency: 366.584109 MHz
        Measured clock frequency: 366.584084 MHz
        Measured clock frequency: 366.583608 MHz
        Measured clock frequency: 366.584112 MHz
        Measured clock frequency: 366.584134 MHz
        Measured clock frequency: 366.584049 MHz
        Measured clock frequency: 366.584090 MHz
        Measured clock frequency: 366.584155 MHz
        Measured clock frequency: 366.584006 MHz
        Measured clock frequency: 366.584182 MHz
        Measured clock frequency: 366.584009 MHz

It takes the median of 1000 samples of the TSC time taken to do a
rdtsc/gettimeofday/rdtsc measurement, then uses that as the threshold
for deciding which of the subsequent 1000000 measurements are accepted.
Then linear regression through the accepted points.

I see a couple of results there which suggests a probable fault in the
filtering algorithm. Perhaps it should simply use the smallest TSC time
taken as the threshold.

Sorry, I'd need permission to post the code.

enjoy,
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 07 2002 - 21:01:13 EST