How to Time a Report

J

Jeff

Is there some code I can run on two reports so that I can see which is
faster or more efficient?

Thanks
 
R

Ron Weiner

As it is unusual to have a report open and close hundreds or thousands of
times in a day, I would guess any differences of less than a second or two
are meaningless. Therefore I would use the sweep second hand of my wrist
watch and open the reports and record the times using a pen and paper. Not
to high tech, not accurate to less than a second or two, but for opening a
report I think it ought to adequate.

If you had to time a process that would operate in a loop that might have
to go thousands of iterations, then you might want to have a look at the
system clock at the start and end of the block of code.

Declare the function as ...
Public Declare Function GetTime Lib "winmm.dll" Alias "timeGetTime" () As
Long
outside of any function or sub in a code module

Then use it in your code like

Debug.Print "Start " ; GetTime
' Your long running code here
' ...
Debug.Print "End "; GetTime

Subtract the Start time from the End time an you have the number of
Milliseconds your code took to execute. This clock is not accurate to one
millisecond but is accurate to something like 30 to 40 milliseconds
depending on a whole host of external factors. So unless you need to time
interactions of sub atomic particles, it is probably close enough.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top