I found this on the Borland Newsgroup somewhere and thought it was worth putting here. This function will return an estimated core processor speed of your PC. Read the comment to see how to use it. If you want to get into the depth of all processor information (normalized & raw frequency, model/stepping/family, type, etc.), I suggest you download Intel's CPUInfo Package or try out my CPUTest project.
{$DEFINE Delphi3Below}
{$IFDEF VER130} //Delphi 5
{$UNDEF Delphi3Below}
{$ELSE}
{$IFDEF VER120} //Delphi 4
{$UNDEF Delphi3Below}
{$ENDIF}
{$ENDIF}
functionGetCpuSpeed: Comp; { Function to return the CPU clock speed only. } { Usage: MessageDlg(Format('%.1f MHz', [GetCpuSpeed]), mtConfirmation, [mbOk], 0); } var t: DWORD; mhi, mlo, nhi, nlo: DWORD; t0, t1, chi, clo, shr32: Comp; 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; {$IFDEF Delphi3Below}
if mhi < 0 then chi := chi + shr32; {$ENDIF} clo := mlo; {$IFDEF Delphi3Below} if mlo < 0 then clo := clo + shr32; {$ENDIF} t0 := chi * shr32 + clo; chi := nhi; {$IFDEF Delphi3Below} if nhi < 0 then chi := chi + shr32; {$ENDIF} clo := nlo; {$IFDEF Delphi3Below} if nlo < 0 then clo := clo + shr32; {$ENDIF} t1 := chi * shr32 + clo;
Result := (t1 - t0) / 1E6; end;