|
Public Class Counter
Private elapsedCount As Long = 0
Private startCount As Long = 0
Public Sub Start()
Clear()
startCount = 0
QueryPerformanceCounter(startCount)
End Sub
Public Sub [Stop]()
Dim stopCount As Long = 0
QueryPerformanceCounter(stopCount)
elapsedCount += (stopCount - startCount)
End Sub
Public Sub Clear()
elapsedCount = 0
End Sub
Public ReadOnly Property Seconds() As Single
Get
Dim freq As Long = 0
QueryPerformanceFrequency(freq)
Return (CSng(elapsedCount) / CSng(freq))
End Get
End Property
Public Overloads Overrides Function ToString() As String
Return [String].Format("{0} seconds", Seconds)
End Function
<System.Runtime.InteropServices.DllImport("KERNEL32")> _
Private Shared Function QueryPerformanceCounter(ByRef lpPerformanceCount As Long) As Boolean
End Function
<System.Runtime.InteropServices.DllImport("KERNEL32")> _
Private Shared Function QueryPerformanceFrequency(ByRef lpFrequency As Long) As Boolean
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.