Attribute VB_Name = "modQPT"
Option Explicit

Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long

Private m_curFrequency As Currency
Private m_HasCounter As Boolean
Private m_StartTime As Currency
Private m_StopTime As Currency

'Call init timer once your app starts up.
' Determine if the computer supports a high performance counter
Sub Timer_InitTimer()
    m_HasCounter = QueryPerformanceFrequency(m_curFrequency)
    m_curFrequency = m_curFrequency * 10000
End Sub

' Returns the frequency of the high performance counter
Private Function Timer_TicksPerSecond() As Long
    Timer_TicksPerSecond = m_curFrequency
End Function

' Call immediately prior to execution of the code being timed
Sub Timer_ResetTimer()
    Call QueryPerformanceCounter(m_StartTime)
End Sub

' Call immediatley after execution of the code being timed
Sub Timer_StopTimer()
    Call QueryPerformanceCounter(m_StopTime)
End Sub

' Returns the number of microseconds that elapsed
Function Timer_Elapsed() As Double
    Timer_Elapsed = (m_StopTime - m_StartTime) / m_curFrequency * 10000
End Function

