- Home
·
- Math/Dates
·
- High Precision Timer for Benchmarking (QueryPerformanceCounter)
High Precision Timer for Benchmarking (QueryPerformanceCounter)
Provides microsecond-level timing using QueryPerformanceCounter. Ideal for benchmarking code performance far more accurately than Timer().
Rate High Precision Timer for Benchmarking (QueryPerformanceCounter)
(0(0 Vote))
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Public Function GetTimeMicroseconds() As Double
Dim cCount As Currency
Dim cFreq As Currency
QueryPerformanceCounter cCount
QueryPerformanceFrequency cFreq
GetTimeMicroseconds = (cCount / cFreq) * 1000000#
End Function
'Usage:
'Dim t1 As Double, t2 As Double
't1 = GetTimeMicroseconds()
'... your code ...
't2 = GetTimeMicroseconds()
'MsgBox "Elapsed: " & (t2 - t1) & " us"
High Precision Timer for Benchmarking (QueryPerformanceCounter) Comments
No comments yet — be the first to post one!
Post a Comment