Title: How do I determine the processor speed?
CODE
function GetCPUSpeed: String;
const
DelayTime = 500;
var
TimerHi, TimerLo: DWORD;
PriorityClass, Priority: Integer;
Speed: Double;
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);
Speed := TimerLo / (1000 * DelayTime);
if Speed = 1000 then
Result := FloatToStr(RoundTo(Speed/1000, -2)) + ' GHz'
else
Result := FloatToStr(RoundTo(Speed, -2)) + ' MHz';
end;
Source:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10290561.html