Option Strict Off Option Explicit On Friend Class clsXTimer Private Sub CODFORCOPY_PAST() '=============================================================================== 'Dieser Codteil wird für die Messung gebraucht '=============================================================================== Dim m_clsXTime As New clsXTimer() m_clsXTime.Calibrate() m_clsXTime.StartTimer() 'Zu messender Code go's here m_clsXTime.StopTimer() End Sub #Region " Class Constructor " Public Sub New() MyBase.New() Class_Initialize_Renamed() End Sub #End Region #Region " Deklarationen " Private Declare Function QueryPerformanceCounter Lib "kernel32" (ByRef lpPerformanceCount As clsXTimer.LARGE_INTEGER) As Integer Private Declare Function QueryPerformanceFrequency Lib "kernel32" (ByRef lpFrequency As clsXTimer.LARGE_INTEGER) As Integer Private Structure LARGE_INTEGER Dim lowpart As Integer Dim highpart As Integer End Structure Private m_liStart As clsXTimer.LARGE_INTEGER Private m_liEnd As clsXTimer.LARGE_INTEGER Private m_liFreq As clsXTimer.LARGE_INTEGER Private m_dblCalibr As Double #End Region #Region " Eigenschaften " Public ReadOnly Property RunTime() As Object Get ' ms RunTime = Math.Abs((Calibr(m_liEnd) - Calibr(m_liStart)) / Calibr(m_liFreq) * 1000 - m_dblCalibr) If RunTime < 0 Then RunTime = 0 End Get End Property #End Region #Region " Timer " Public Sub Calibrate() Call QueryPerformanceCounter(m_liStart) Call QueryPerformanceCounter(m_liEnd) m_dblCalibr = (Calibr(m_liEnd) - Calibr(m_liStart)) / Calibr(m_liFreq) * 1000 ' Millisekunden. End Sub Public Sub StartTimer() Call QueryPerformanceCounter(m_liStart) End Sub Public Sub StopTimer() Call QueryPerformanceCounter(m_liEnd) MsgBox("Verstichene Zeit=" & Format(RunTime, "0.00 ms")) End Sub Public Function Stop_nd_GetTime() As String Call QueryPerformanceCounter(m_liEnd) Return Format(RunTime, "0.00 ms") End Function Private Function Calibr(ByRef liX As clsXTimer.LARGE_INTEGER) As Double Calibr = liX.lowpart + liX.highpart * 4294967296.0# End Function Private Sub Class_Initialize_Renamed() Call QueryPerformanceFrequency(m_liFreq) End Sub #End Region End Class