var
CPUClock: extended;
function GetCPUTick: Int64;
asm
DB $0F,$31 // this is RDTSC command. Assembler, built in Delphi,
// does not support it,
// that is why one needs to overcome this obstacle.
end;
function CalibrateCPU: int64;
var
t: cardinal;
begin
t := GetTickCount;
while t=GetTickCount do;
Result := GetCPUTick; //get the time-stamp counter value
while GetTickCount<(t+400) do; // delay for 0,4 sec
Result := GetCPUTick - result; // clock cycle number in 0,4 second
CPUClock := 2.5e-6*Result; // clock cycle number in 1 microsecond
end;
function TicksToStr(const Value: int64): string;
begin
Result := FloatToStrF(Value/CPUClock,fffixed,10,2)+ ' ms';
end;