Hi
I am using the QueryPerformanceCounter to time a piece of code. I need timing in microseconds.
My code compiles okay but the end result is 0 I think this is because my function is not accessing the kernel32.dll and so is not passing any value in the parameter. Do I have to do anything other than the Declare Function statements
This is what the code looks like at present
Option Explicit
Private Declare Function QueryPerformanceCounter Lib “KERNEL32” _
(lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib “KERNEL32” _
(lpPerformanceCount As Currency) As Long
Sub BinarySearch()
Dim sec As Currency
Dim secOut As Currency
ProfileStart sec
Do the Binary Search
ProfileStop sec, secOut
End Sub
Sub ProfileStart(secStart As Currency)
Dim secFreq As Currency
If secFreq = 0 Then QueryPerformanceFrequency secFreq
QueryPerformanceCounter secStart
End Sub
Sub ProfileStop(secStart As Currency, secTiming As Currency)
Dim secFreq As Currency
QueryPerformanceCounter secTiming
If secFreq = 0 Then
secTiming = 0 ‘Handle old system with no high-resolution timer
Else
secTiming = (secTiming – secStart) / secFreq
End If
lblCheck.Visible = True
lblCheck.Caption = secTiming
End Sub
Now the code looks okay to me (famous last words) So what am I missing please?