   Get CPU Frequency
  Hi!Can somebody describe in words how i can calculate the CPU Frequency?Thanks, Christian 
  check out the system information class link in my sig. It''s a fully featured class that calcultes the cpu frequency, what teh cpu supports, the chip make and model, how much available ram and various other things.   | TripleBuffer Software || Plug-in Manager :: System Information Class :: C++ Debug Kit :: DirectX Tutorials :: Awesome Books | ;  merci ;quote:Original post by IFooBar   check out the system information class link in my sig. It's a fully featured class that calcultes the cpu frequency, what teh cpu supports, the chip make and model, how much available ram and various other things.hmm.. maybe my reference value was pretty wrong and the changes i made weren't really helping, but i was getting results of about 1739500000 instead of 1737250000 (about the average of what different tools were claiming). thats just off by 0.12% though.timeStart = timeGetTime();while(timeGetTime() == timeStart) timeStart=timeGetTime();while (timeGetTime()-timeStart < 1);startTick = GetCPUTicks();timeStart = timeGetTime();while(timeGetTime()-timeStart < 1000);endTick = GetCPUTicks();cpuSpeed=endTick - startTick + overhead;changing it to the above changed the result to about 1737250000, which would be only 0.02% off. all assuming the reference value i was trying to approach wasnt completely wrong.also, reducing it to this didnt cause any measurable change to the result:overhead = (unsigned)-(GetCPUTicks()-GetCPUTicks());__int64 timeStart = timeGetTime()+1;while (timeGetTime() < timeStart);__int64 startTick = GetCPUTicks();timeStart = timeGetTime()+1000;while(timeGetTime() < timeStart);__int64 endTick = GetCPUTicks();cpuSpeed=(endTick - startTick) + overhead;but as i'm not too much into the technical part i have no clue if its just luck, coincidence or limited to work with only some cpus.   [edited by - Trienco on February 12, 2004 1:01:19 PM];  Just an interesting note I discovered while playing around with this class:It appears that, much like the hard drive industry, CPUs are also clocked on a 1MHz = 1000000Hz system, as opposed to 1048576Hz.My processor is running at 1991MHz, while reporting 2088MHz.I''ve tested this with both Intel and AMD processors, and it seems to hold true for both. ;  there has never been a factor of 1024 for speed. thats for bytes only.which one reported the higher number? the class or some system tool? what you should keep in mind: there is no way to measure the exact speed of your cpu. and the best you can hope for is a good approximation (its even more useless for intel cpus that adjust their clock speed depending on heat).above class reported 5Mhz more than other tools and they all report more than the 1736.8 it should be acoording to the bios settings (1737.6 and 1739.5). which reminds me: whats the exact fsb clock speed? exactly 133 or 133.6? im wondering if the tool is reading the values from somewhere or is just guessing from some measured values. ;quote:Original post by Trienco   and the best you can hope for is a good approximation (its even more useless for intel cpus that adjust their clock speed depending on heat).Indeed. B5:IFH (http://ifh.firstones.com/), for example, uses this method, the result of which is that the game''s clock runs four times faster than it should on SpeedStep processors.;  On a related note, and without meaning to hijack, how would one go about spoofing the method used to detect chip speed in IFooBar''s class so that it returns an arbitrary value?   www.coldcity.comcode, pics, life ;  If IFooBar''s class is more than you need, these functions should work.just doDWORD mhz = MHZ(); void CPUtick(DWORD* hi,DWORD* lo){DWORD h,l;__asm{RDTSCmov [h],edxmov [l],eax}*hi=h;*lo=l;}DWORD MHZ() {DWORD h,l,lasttick=0;DWORD time1,time2;time1=GetTickCount();time2=time1;CPUtick(&h,&l);while(time2-time1<1000){time2=GetTickCount();}CPUtick(&h,&lasttick);h=(lasttick-l)/1000000;return h;};quote:Original post by Trienco  there has never been a factor of 1024 for speed. thats for bytes only.Then why is my 120GB hard drive only 111.76GB?It just seems to me that being a binary piece of hardware, it would make sense to measure it with the binary method (ticks/(2^20)). 