Board index » delphi » CPU Speed Determination...

CPU Speed Determination...

I am trying to determine what speed a processor is, but I keep running
into walls ... I've checked into the Win32 API function
GetSystemInformation,
which in the Win32 API returns a _SYSTEM_INFO struct, and Delphi's got it
mapped
to a TSystemInfo obj... The problem is this thing has all sorts of useful
information about
the number of processors, the type of the processor (pentium, whatever) ..
but it doesn't
have the CPU speed in there (in any kind of units).

If anyone knows of a Win32 API routine or a Delphi3/4 routine to get the CPU
speed of a given system, that would be extremely helpful!!

Thanks,
        Kevin

:)

 

Re:CPU Speed Determination...


Quote
Kevin S Hoffman wrote:

> I am trying to determine what speed a processor is, but I keep running
> into walls ... I've checked into the Win32 API function

I believe queryPerformanceFrequency will do the trick on Pentium or
greater CPU's

Bob Lee

Re:CPU Speed Determination...


I made a call to queryperformancefrequency by doing:

Var
  Freq : Int64;

Begin

 queryPerformanceFrequency(Freq);

End;

And it returned the same value all the time, 1193182.

This is apparently the value in 'counts per second' ... how does this value
translate into the MegaHertz rating of the CPU?

Quote
Robert Lee wrote in message <3635FD0B.42DEF...@nwu.edu>...
>Kevin S Hoffman wrote:

>> I am trying to determine what speed a processor is, but I keep running
>> into walls ... I've checked into the Win32 API function

>I believe queryPerformanceFrequency will do the trick on Pentium or
>greater CPU's

>Bob Lee

Re:CPU Speed Determination...


Quote
Kevin S Hoffman wrote:

> I made a call to queryperformancefrequency by doing:

> Var
>   Freq : Int64;

> Begin

>  queryPerformanceFrequency(Freq);

> End;

> And it returned the same value all the time, 1193182.

> This is apparently the value in 'counts per second' ... how does this value
> translate into the MegaHertz rating of the CPU?

My mistake, I should have looked at it closer.  It doesn't use the
mechanism that I thought it did.  This will do the trick:

function microtime:int64;
asm
        DB 0FH
        DB 031H
end;

function calibrateCPU:integer;
var
        t1:dword;
        stop,start:int64;
begin
        t1:=gettickcount;
        while t1=gettickcount do;
                start:=microtime;
        while gettickcount<(t1+1000) do;
                stop:=microtime;
        result:=stop-start;
end;

Returns the approx frequency in Hz.

Bob Lee

Re:CPU Speed Determination...


Bob

Is it true that your code would not work with 486s?

Quote
>My mistake, I should have looked at it closer.  It doesn't use the
>mechanism that I thought it did.  This will do the trick:

>function microtime:int64;
>asm
> DB 0FH
> DB 031H
>end;

>function calibrateCPU:integer;
>var
> t1:dword;
> stop,start:int64;
>begin
> t1:=gettickcount;
> while t1=gettickcount do;
> start:=microtime;
> while gettickcount<(t1+1000) do;
> stop:=microtime;
> result:=stop-start;
>end;

>Returns the approx frequency in Hz.

>Bob Lee

Re:CPU Speed Determination...


Quote
1191news wrote:
> Bob

> Is it true that your code would not work with 486s?

It is true.  It also won't work on Cx586's and some/most/all/? of AMD's
and Cyrix's and the others.

Bob Lee

Re:CPU Speed Determination...


Quote
>It is true.  It also won't work on Cx586's and some/most/all/? of AMD's
>and Cyrix's and the others.

Q: What will happen on those processors?
Q2: How to detect if processor supports your code?

Primoz

Other Threads