Не знаю можно ли в Паскале вызвать GetTickCount, но вот такой пример есть(значение возвращает в герцах):
| Код | (** This function is not as accurate **) function OldGetCpuSpeed: Comp; (** Uses RDTSC Command to get the Processor Timer count **) var t: DWORD; mhi, mlo, nhi, nlo: DWORD; t0, t1, chi, clo, shr32: Comp; begin Result:=0; shr32 := 65536; shr32 := shr32 * 65536;
(** Get a start time **) t := GetTickCount; while t = GetTickCount do begin end; asm DB 0FH DB 031H (** RDTSC Opcode retrieves 64-bit tick count since boot **) mov mhi,edx (** 32-bit Ticks Hi **) mov mlo,eax (** 32-bit Ticks Lo **) end;
(** Look 1 second later **) while GetTickCount < (t + 1000) do begin end; asm DB 0FH DB 031H (** RDTSC **) mov nhi,edx mov nlo,eax end;
(** See how many Processor Timer Ticks have elapsed **) chi := mhi; if mhi < 0 then chi := chi + shr32; clo := mlo; if mlo < 0 then clo := clo + shr32;
t0 := chi * shr32 + clo;
chi := nhi; if nhi < 0 then chi := chi + shr32; clo := nlo; if nlo < 0 then clo := clo + shr32;
t1 := chi * shr32 + clo;
Result := Round(t1 - t0); end; | |