Created
January 11, 2021 20:18
-
-
Save maxkleiner/32ec49c2ae95157fd13033e09238afab to your computer and use it in GitHub Desktop.
CPUClockFrequency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const | |
SHighResCounterError = 'High resolution counter error'; | |
function CPUClockFrequency: Word64; | |
var | |
Freq : int64; | |
begin | |
Freq := 0; | |
if not QueryPerformanceFrequency(Freq) then | |
xraise (ETimerError2.Create(SHighResCounterError)); | |
if Freq = 0 then | |
xraise (ETimerError2.Create(SHighResCounterError)); | |
Result := Word64(Freq); | |
end; | |
procedure InitHighResolutionCounter; | |
var | |
Freq : Word64; | |
begin | |
Freq := CPUClockFrequency; | |
HighResolutionFrequency := Freq; | |
HighResolutionMillisecondFactor := Freq div 1000; | |
HighResolutionMicrosecondFactor := Freq div 1000000; | |
if HighResolutionMicrosecondFactor = 0 then | |
Xraise (ETimerError2.Create(SHighResCounterError)); | |
HighResolutionCounterInit := True; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment