Board index » delphi » Detecting CPU speed / CPU load

Detecting CPU speed / CPU load

I'm looking for a way to get the cpu-speed and the cpu-load (how many %
of the time is the processor really working). Who knows how to do this
in Delphi 4?

Thanks!
Eric Barten

 

Re:Detecting CPU speed / CPU load


This will get the CPU
var
t: DWORD; mhi, mlo, nhi, nlo: DWORD;
t0, t1, chi, clo, shr32: Integer;
begin
shr32 := 65536;
shr32 := shr32 * 65536;

t := GetTickCount;
while t = GetTickCount do begin end;
asm
DB 0FH
DB 031H
mov mhi,edx
mov mlo,eax
end;
while GetTickCount < (t + 1000) do begin end;
asm
DB 0FH
DB 031H
mov nhi,edx
mov nlo,eax
end;
chi := mhi;
// if mhi < 0 then chi := chi + shr32;
clo := mlo;
// if mlo < 0 then clo := clo + shr32;
t0 := chi * shr32 + clo;
chi := nhi;
// if nhi < 0 then chi := chi + shr32;
clo := nlo;
// if nlo < 0 then clo := clo + shr32;
t1 := chi * shr32 + clo;
Label1.Caption:= IntToStr((t1 - t0) div 1000000);
end;

Venlig Hilsen Lasse Valeur, Danmark
e.val...@get2net.dk
http://hjem.get2net.dk/Mr_Lz
---------------------------------------------------
Delphi | WebWriter | Seti@home | SetiSpy |
---------------------------------------------------
Eric Barten <e.r.bar...@student.utwente.nl> skrev i en
nyhedsmeddelelse:39468BF4.A4247...@student.utwente.nl...

Quote
> I'm looking for a way to get the cpu-speed and the cpu-load (how many %
> of the time is the processor really working). Who knows how to do this
> in Delphi 4?

> Thanks!
> Eric Barten

Re:Detecting CPU speed / CPU load


Thanks!

Isn't there a way to do this by using some system call? I found some
information about a processor object for winNT; win95/98 is still a big
mystery. This code is doing fine; anybody who knows how to get or
calculate the processor load? (The Windows' system monitor knows how to
do this...)

Eric

Quote
NetZonic wrote:

> This will get the CPU
> var
> t: DWORD; mhi, mlo, nhi, nlo: DWORD;
> t0, t1, chi, clo, shr32: Integer;
> begin
> shr32 := 65536;
> shr32 := shr32 * 65536;

> t := GetTickCount;
> while t = GetTickCount do begin end;
> asm
> DB 0FH
> DB 031H
> mov mhi,edx
> mov mlo,eax
> end;
> while GetTickCount < (t + 1000) do begin end;
> asm
> DB 0FH
> DB 031H
> mov nhi,edx
> mov nlo,eax
> end;
> chi := mhi;
> // if mhi < 0 then chi := chi + shr32;
> clo := mlo;
> // if mlo < 0 then clo := clo + shr32;
> t0 := chi * shr32 + clo;
> chi := nhi;
> // if nhi < 0 then chi := chi + shr32;
> clo := nlo;
> // if nlo < 0 then clo := clo + shr32;
> t1 := chi * shr32 + clo;
> Label1.Caption:= IntToStr((t1 - t0) div 1000000);
> end;

> Venlig Hilsen Lasse Valeur, Danmark
> e.val...@get2net.dk
> http://hjem.get2net.dk/Mr_Lz
> ---------------------------------------------------
> Delphi | WebWriter | Seti@home | SetiSpy |
> ---------------------------------------------------
> Eric Barten <e.r.bar...@student.utwente.nl> skrev i en
> nyhedsmeddelelse:39468BF4.A4247...@student.utwente.nl...
> > I'm looking for a way to get the cpu-speed and the cpu-load (how many %
> > of the time is the processor really working). Who knows how to do this
> > in Delphi 4?

> > Thanks!
> > Eric Barten

Other Threads