DebugTimer
Have you ever been asked: Which part of the routine is taking so long? or did you ever wonder what function was bogging your app down, or did you ever just want to time a particular statement or function? Welcome to DebugTimer. It's not a resource hog and uses no active-x controls... just the built-in Timer function in VB. This is a very easily implemented class module that allows you to time any line(s) of code or functions or whatever. You can even use multiple timers or nest them. I wrote this to determine the length of time it took to perform various stored procedures, and it worked great. If you have a similar need, I'm sure this will do the trick.
Résumé par IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
'Add a new Form to your project, and add 3 command buttons to the
'form (named Command1, Command2, and Command3). Then just
'paste the following code into the form:
Option Explicit
Dim i As Integer
Dim dbg As New clsDebugTimer
Private Sub Command1_Click()
Me.MousePointer = vbHourglass
'EXAMPLE 1 - VERY BASIC USAGE
' Start the timer
dbg.Begin
'Do something that will take a little time
For i = 0 To 25000: DoEvents: Next
'By default, calling the ShowElapsed method
'will display the elapsed time in the immediate window
dbg.ShowElapsed
Me.MousePointer = vbDefault
End Sub
Private Sub Command2_Click()
Me.MousePointer = vbHourglass
'EXAMPLE 2 - USING THE PARAMETERS
'Start the timer, this time passing a
'timer index and a description
dbg.Begin 0, "Loop from 0 to 25000"
'Do something that takes time
For i = 0 To 25000: DoEvents: Next
'Display the elapsed time for timer index 0 in a message box
dbg.ShowElapsed outMsgBox, 0
Me.MousePointer = vbDefault
End Sub
Private Sub Command3_Click()
Me.MousePointer = vbHourglass
'EXAMPLE 3 - USING MULTIPLE TIMERS
'Start the first timer- we'll use an index of 1
'timer index and a description
dbg.Begin 1, "Total Time"
'Start a second timer- (index 2)
'timer index and a description
dbg.Begin 2, "Count from 0 to 25000"
'Do something that takes time
For i = 0 To 25000: DoEvents: Next
'Display the elapsed time for the second timer
dbg.ShowElapsed outImmediateWindow, 2
'perform another loop like the one we just did above
dbg.Begin 2, "Count from 0 to 24999"
'Do something that takes time
For i = 0 To 24999: DoEvents: Next
'Display the elapsed time for the second timer
dbg.ShowElapsed outImmediateWindow, 2
'Now display the elapsed time for the first timer
dbg.ShowElapsed outImmediateWindow, 1
Me.MousePointer = vbDefault
End Sub
Upload