Lenguaje de programación Borland Delphi
Os mostramos una función para obtener la velocidad del procesador (CPU) usando código ensamblador en Delphi (ASM).
function obtenerVelocidadCPU : dword;
var
velocidadCPU : dword;
begin
SetpriorityClass(getcurrentprocess,REALTIME_PRIORITY_CLASS);
SetThreadPriority(getcurrentThread,THREAD_PRIORITY_TIME_CRITICAL);
asm
push eax
push edx
push ecx
push 1000
call sleep
dw $310F
add eax,edx
mov velocidadCPU,eax
push edx
xor eax,eax
push 1000
call sleep
pop edx
dw $310F
add eax,edx
sub eax,velocidadCPU
mov velocidadCPU,eax
pop ecx
pop edx
pop eax
end;
result := round((velocidadCPU / 1000000) / 3) * 3;
end;
Un ejemplo de uso:
txtInfo.Lines.Add(IntToStr(obtenerVelocidadCPU) + 'MHz')
Publicado el: 2008-03-17