Определение частоты процессора
|
// // Determinate CPU Freq // //
function GetCPUSpeed: Double; const DelayTime = 500; var TimerHi : DWORD; TimerLo : DWORD; PriorityClass : Integer; 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 // rdtsc MOV TimerLo, EAX MOV TimerHi, EDX end; Sleep(DelayTime); asm DW 310Fh // rdtsc SUB EAX, TimerLo SBB EDX, TimerHi MOV TimerLo, EAX MOV TimerHi, EDX end; SetPriorityClass(GetCurrentProcess, PriorityClass); Result := TimerLo / (1000.0 * DelayTime); end;
// Usage ...
LabelCPUSpeed.Caption := Format('CPU speed: %f MHz', [GetCPUSpeed]); |