All Delphi

Everything You Want To Know From VCL, Tips To Snippet All Everything About Delphi And CodeGear Related

    Search

  • Sponsors

  • Spottt
    Spottt

How To Get Your Cpu Speed ?

16th April 2008

For you guys that need to know what is your cpu speed we got the snippet to get the cpu timer speed here …

function GetCPUSpeed: Double;
const
DelayTime = 500;
var
  TimerHi, TimerLo: DWORD;
  PriorityClass, Priority: Integer;
begin
  PriorityClass := GetPriorityClass(GetCurrentProcess);
  Priority := GetThreadPriority(GetCurrentThread);
  SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
  SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
  Sleep(10);
  asm
    dw 310Fh
    mov TimerLo, eax
    mov TimerHi, edx
  end;
  Sleep(DelayTime);
  asm
    dw 310Fh
    sub eax, TimerLo
    sbb edx, TimerHi
    mov TimerLo, eax
    mov TimerHi, edx
  end;
  SetThreadPriority(GetCurrentThread, Priority);
  SetPriorityClass(GetCurrentProcess, PriorityClass);
  Result := TimerLo / (1000000 * DelayTime);
end;
Rate this:
2.7

One Response to “How To Get Your Cpu Speed ?”

  1. no image no imageYudi Suteja (Who am I?) (Who am I?) Says:

    Hi Eddy,

    Congrats on your new website. I just knew your website today, so I visited here and it looks great. Keep up the good work.

    Yudi

    Rate this:
    1.7
    (Who am I?)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>