May 22, 2024, 05:21:38 AM


Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........

Approximating CPU speed

Started by Ionic Wind Support Team, July 22, 2006, 05:16:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ionic Wind Support Team

While I was playing with timers I came up with this:

import int QueryPerformanceFrequency(int64 *lpFrequency);
import int QueryPerformanceCounter(int64 *lpPerformanceCount);

global sub main()
int64 freq;
int64 countstart,countend;
int64 startcpu,endcpu;
countend = countstart;
startcpu = readts();
while(countend - countstart) < freq
endcpu = readts();
while GetKey() = "";

sub readts(),int64
int64 ret;
lea esi,[ebp]
mov [esi-8],eax
mov [esi-4],edx
return ret;

Which is a method of approximating your current CPU speed.  However it will probably only work on single core machines and may give silly results.  You were warned ;)

Ionic Wind Support Team


John S

compile this one in a console!
John Siino, Advanced Engineering Services and Software

Ionic Wind Support Team

Yes it has a print statement so it needs a console. 

Post your results here too just to see how it works on other machines ;)
Ionic Wind Support Team


2210 MHz here which is pretty correct as theoretically it should be 2200 MHz. (AMD X2 4400+)


Rock Ridge Farm (Larry)


1694 Mhz on my IBM laptop. rated at 1700 Mhz.
Pretty good approximation.


2087 Mhz using a 64 Bit AMD processor rated at 2000 Mhz

Looks to be pretty darned accurate on a wide variety of CPU's.  8)


Ionic Wind Support Team

That's cool.

You can use the readts function to time and tweak code speed too. 

start = readts();
...some long code your trying to make faster
end = readts();

Ionic Wind Support Team

John Syl.

3591 Mhz

P4 660 HT 3.6Ghz ....  I've lost  9 Mhz  thats equivalent to an 8086 and Z80!!!   ;D

Intel 3.6 p4 ht, XP home,2 gb mem, 400 gb hd 20gb raid 0, Nvidia 6600le.
AMD k6-2 500, 40gb.

Started on PDP11 Assembler, BASIC, GWBASIC, 6502, Z80, 80x86, Java, Pascal, C, C++, 
IBasic (std & pro), Aurora, EBasic.  (Master of none, but it's been fun!)


QuoteI've lost  9 Mhz  thats equivalent to an 8086 and Z80!!!   

oooooooooh... must hace been a TURBO XT! ;D
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library