|
|
|
Click here to copy the following block |
Option Explicit
Private Declare Function QueryPerformanceFrequencyAny Lib "kernel32" Alias _ "QueryPerformanceFrequency" (lpFrequency As Any) As Long Private Declare Function QueryPerformanceCounterAny Lib "kernel32" Alias _ "QueryPerformanceCounter" (lpPerformanceCount As Any) As Long
Dim frequency As Currency Dim startTime As Currency Dim endTime As Currency Dim totTime As Currency
Sub StartTimer(Optional ByVal ResetTotalTime As Boolean) QueryPerformanceCounterAny startTime If ResetTotalTime Then totTime = 0 End Sub
Function StopTimer() As Double StopTimer = ElapsedTime totTime = totTime + (endTime - startTime) startTime = 0 End Function
Property Get ElapsedTime() As Double If startTime = 0 Then Exit Property QueryPerformanceCounterAny endTime ElapsedTime = (endTime - startTime) / frequency End Property
Property Get TotalTime() As Double If startTime = 0 Then TotalTime = totTime / frequency Else TotalTime = (totTime + (endTime - startTime)) / frequency End If End Property
Property Get FormatTime(msg As String, Optional seconds As Double = -1, _ Optional ByVal decDigits As Integer = 7) As String If seconds < 0 Then seconds = ElapsedTime() FormatTime = Replace(msg, "###", CStr(Round(seconds, decDigits))) End Property
Property Get Precision() As Double Precision = 1 / (frequency * 10000#) End Property
Private Sub Class_Initialize() If QueryPerformanceFrequencyAny(frequency) = 0 Then Err.Raise 1001, , "This system doesn't support high-res timing" End If StartTimer End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|