I've been using QueryPerformanceCounter a bit lately and I've noticed some posts using it of late.
Some of you may find the following handy.
Some of you may find the following handy.
Code:
#COMPILE EXE #Register None #Dim All #TOOLS OFF %NOMMIDS = 1 %NOGDI = 1 #Include "WIN32API.INC" '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Macro InitializeTimer Local qFreq, qOverhead, qStart, qStop As Quad Local f As String f = "#####.##" QueryPerformanceFrequency qFreq QueryPerformanceCounter qStart ' Intel suggestion. First use may be suspect QueryPerformanceCounter qStart ' So, wack it twice <smile> QueryPerformanceCounter qStop qOverhead = qStop - qStart ' Relatively small End Macro Macro StartTimer = QueryPerformanceCounter qStart Macro StopTimer = QueryPerformanceCounter qStop Macro TimeTaken = Using$(f,(qStop - qStart - qOverhead)*1000/qFreq) + "ms" '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function PBMain( ) As Long Local i, n As Long InitializeTimer StartTimer ' Example For i = 1 To 1000000 n = Rnd(0,255) Next StopTimer MsgBox TimeTaken END FUNCTION
Comment