Message-ID: <3B637F55.B6DF0FD2@hotmail.nospam.com> From: Ian Rees X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Cpu speed detection using DJGPP? References: <68C4CF842BD2D411AC1600902740B6DA02CDC45E AT mcoexc02 DOT mlm DOT maxtor DOT com> <458df9bf DOT 0107242347 DOT 5725a1a0 AT posting DOT google DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 54 Date: Sat, 28 Jul 2001 23:13:25 -0400 NNTP-Posting-Host: 63.80.121.38 X-Trace: eagle.america.net 996376404 63.80.121.38 (Sat, 28 Jul 2001 23:13:24 EDT) NNTP-Posting-Date: Sat, 28 Jul 2001 23:13:24 EDT Organization: 24hoursupport.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Seems to work on my computer, too. I have a 1Ghz. Athlon Processor running Win98se and it shows 1000+/- about 3 Mhz . I modified the program a little to make it average 100 results and it averages at 1000Mhz, exactly where it sould be. -Ian- Daniel Friberg wrote: > Thanks for all the replies! This is what I came up with and it seems > too work fine on my K6-2 computers. > > #include > #include > > int main() > { > unsigned long val1, val2,speed; > unsigned long tm1,tm2,i ; > double time; > > tm1 = uclock(); > asm > ( > "rdtsc\n > movl %%eax, %0" > : "=g" (val1) > : /* no inputs */ > : "ax", "dx" > ); > for(i=0;i<100000;i++); > tm2 = uclock(); > asm > ( > "rdtsc\n > movl %%eax, %0" > : "=g" (val2) > : /* no inputs */ > : "ax", "dx" > ); > > time = (double) (tm2 - tm1) / UCLOCKS_PER_SEC; > speed = (val2-val1)/time/1000000; > > printf("Time elapsed: %f seconds.\n",time); > printf("Cycles executed: %d.\n",val2-val1); > printf("Calculated speed: %dMHz.\n",speed); > > return 0; > } > > //Daniel