function RdTSC : int64; register;
asm
db $0f, $31
end;
function GetCyclesPerSecond : int64;
var
hF, T, et, sc : int64;
begin
QueryPerformanceFrequency(hF); // HiTicks / second
QueryPerformanceCounter(T); // Determine start HiTicks
et := T + hF; // (Cycles are passing, but we can still USE them!)
sc := RdTSC; // Get start cycles
repeat // Use Hi Perf Timer to loop for 1 second
QueryPerformanceCounter(T); // Check ticks NOW
until (T >= et); // Break the moment we equal or exceed et
Result := RdTSC - sc; // Get stop cycles and calculate result
end;
|