function RDTSC : Int64; assembler;
asm
db $0F, $31 // opcode for RDTSC
end;
function RDQPC : Int64;
begin
QueryPerformanceCounter(result);
end;
function CPUSpeed : Integer;
var
f,tsc,pc : Int64;
begin
if QueryPerformanceFrequency(f) then
begin
Sleep(0);
pc := RDQPC;
tsc := RDTSC;
Sleep(100);
pc := RDQPC-pc;
tsc := RDTSC-tsc;
result := round(tsc*f/(pc*1000000));
end
else
result := -1;
end;
// Kullanimi:
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.caption := Format('%d Mhz', [CPUSpeed]);
end;