`Charles Cazabon <charlesc-linux@qcc.sk.ca> wrote:>Dag Wieers <dag@digibel.be> wrote:>> i don't think it really is random, maybe it differs beause the state of>> the processor differs little. can't we use this to statistically measure>> something about that processor ?>> >> the real question is: what causes these fluctuations ?>> >You're talking +-1000 cycles out of 200 million.  This could easily be due>to ambient temperature differences or other environmental factors.Just for kicks I decided to let mhz.estimate run for a while in a loop, thatway I get thousands more quite-possibly-less-accurate statistics. Out of59000 runs, here are the most deviant 20:374.865421374.865944374.865967374.866508374.866577374.867146374.867292374.867333374.867610374.867645[...]374.947681374.947712374.947716374.947962374.952847374.960404378.688356378.688474378.689010378.725015Another interesting statistic:cat mhz.estimate.output | wc -l  59218cat mhz.estimate.output | cut -f1 -d' ' | sort | uniq | wc -l  11147After running gnuplot over it, I see a very straight line. It appears mymotherboard's clock is not affected by temperature. There are someinteresting dips and jolts but nothing resembling a curve.Adding up all the numbers and dividing by 59218 gives us:374.929090476, meaning the max deviation is -.063669476/+3.795924524.The average deviation, something much more useful, I'm too lazy tocalculate. :)Stripping out anything so deviant to not be in the 374 range, our plot lookslike so:http://frantica.lly.org/~rcw/mhz-plot-19990111.pngmhz.estimate.c is below:#include <stdio.h>#include <unistd.h>#include <sys/time.h>/* returns number of clock cycles since last reboot */__inline__ unsigned long long int rdtsc(){	unsigned long long int x;	__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));	return x;}main (){	/* find out the MHz of the processor by dividing	 * clock cycles by seconds */		struct timezone tz;        struct timeval tvstart, tvstop;        unsigned long long int cycles[2]; /* gotta be 64 bit */	unsigned int microseconds; /* total time taken */		bzero(&tz, sizeof(tz));	gettimeofday(&tvstart, &tz);	cycles[0] = rdtsc();	gettimeofday(&tvstart, &tz);#ifdef VERBOSE	printf("Clock cycles at start: %Lu\n", cycles[0]);#endif	usleep(1000000);		cycles[1] = rdtsc();	gettimeofday(&tvstop, &tz);	microseconds = ((tvstop.tv_sec-tvstart.tv_sec)*1000000)+(tvstop.tv_usec-tvstart.tv_usec);#ifdef VERBOSE		printf("Clock cycles at end:   %Lu\n", cycles[1]);	printf("Microseconds elapsed:  %u\n", microseconds);#endif		printf("%f MHz processor.\n", (float)(cycles[1]-cycles[0])/microseconds);}-- Robert Woodcock - rcw@debian.org"Unix and C are the ultimate computer viruses" -- Richard Gabriel-To unsubscribe from this list: send the line "unsubscribe linux-kernel" inthe body of a message to majordomo@vger.rutgers.eduPlease read the FAQ at http://www.tux.org/lkml/`