timing a sub procedure
Hi Geena,
You do not show how you run Rowan's code repeatedly, but from the problem
you report, I would guess that you have adapted Rowan's code something like:
Sub MsgTimer()
Dim StartTime As Single
Dim EndTime As Single
Dim i As Long
StartTime = Timer
For i = 1 To 10 <<== Loop inserted here
'Your code here
EndTime = Timer
Debug.Print "Time taken: " & EndTime - StartTime & " seconds"
Next i
End Sub
If your amended code looks like this, you can resolve the encounterd problem
by moving the loop initiation line:
For i = 1 To 10
above the line:
StartTime = Timer
This way, the timer will be reinitialised at each loop pass.
If this is not the problem, post back with the adaptation of Rowans's code
that you used.
I presume that you did not experience a similar problem with my suggested
code ( which is completely analagous to Rowan's), simply because I included
the repeat loop structue in my code.
---
Regards,
Norman
"geena" wrote in message
...
guys..i hv a problem
rowan's way at first work ok..then as i keep running the procedure for
same
case many times to test the duration of each time it run, the duration
keeps
increasing..
first time it was only 5 seconds..i test it for 5 times..
now it is 11 seconds for the 5th time..
why does this happen?how to rectify this?
any idea?
thanks
"geena" wrote:
guys..thanks so much!!it works perfectly..
you guys are great!
-geena-
"geena" wrote:
how do i write in vba to know how long a Sub procedure (macro) runs?
I want to be able to tell users how long does each execution take for
different test cases (simulation time) after each run.
Thanks
|