Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debug.print time between functions? 1

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I have some functions, on certain forms in an application, which take a while to run. I want to set up some simple debug.print messages to capture the time I start the function, and the time I start and finish each step of the function. This way, I can isolate which step is taking the longest and work to improve that lag.

Make sense? Anyone know a quick and easy way to do this. From my main menu, one form I go to is an "add/find" form, which has to load the rowsource for 2 queries, after running a stored proc to reset the flags in their underlying table. Just wanting to figure out what part of that is the slowest part, and see what I can do to speed it up. Thanks!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
In your vba, did you try putting [tt]Debug.Print "YourFunctionName Started at: " & Now
[/tt] and [tt]Debug.Print "YourFunctionName Completed at: " & Now
[/tt]before and after each command or function? Or is there something more complicated that I'm missing? (Changing "yourfunctionname" to the actual name of the item you plan to check the time on.
 
No, you got it. I ended up realizing I could do the same, I just formatted it differently.

Code:
Debug.Print "Start doing step N"
Debug.Print Format(Now(), "hh-mm-ss")

blah blah step n

Debug.Print "finish doing step N"
Debug.Print Format(Now(), "hh-mm-ss")

Thanks!


misscrf

It is never too late to become what you could have been ~ George Eliot
 
You may also do:

Code:
Dim dat As Date

dat = Now()[green]
'... blah blah step N[/green]
Debug.Print "Step N took " & DateDiff("s", dat, Now()) & " seconds"
dat = Now()[green]
'... blah blah step X[/green]
Debug.Print "Step X took " & DateDiff("s", dat, Now()) & " seconds"

Lazy approach, I don't want to calculate the difference in my head.... :)

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top