mesuare excute time

zezo2021

Member
Local time
Today, 21:59
Joined
Mar 25, 2021
Messages
412
Hello friends

I have a datasheet form bound to query I do some enhancement to query
I want to measure the time taken to load data in datasheet form to see is enhanced or not
 
:D
checked
but not understand how to use
 
Let's say that you have something you want to time as accurately as possible without getting involved in complex API calls. (Most of us are like that.) So let's call this activity X. Don't care what it really is.

Code:
Dim XStart as Single
Dim XFinish as Single
Dim XElapsed as Single
...
XStart = Timer()
X
XFinish = Timer()
XElapsed = XFinish - XStart
...

In that sequence, XElapsed will be the number of seconds and fractions of a second between the start and finish of whatever X happens to be. I sort of simplified it by showing every step at a low level, though you could probably collapse two of those statements into one if you were being picky.

NOTE: The internal reference for the Timer() function is 1/60th of a second, so the fraction is good to 1 decimal point and MAYBE a part of the next decimal position. What you get is NOT 1/100th of a second accurate.

If you are outputting this elapsed time in text, use something like Format( XElapsed, "###.##" ) and no more than that.

The number here is NOT repeat NOT compatible with date/time variables without some effort. It is seconds and fractions since midnight. I also don't know if you get other fractions if you are on a non-USA power grid that offers 50 Hz vs. 60 Hz alternating current.

It is theoretically possible to use the HiRes timer functions but you will need to do some serious research to get those extra decimals. Usually, if you need the extra decimals, you should be doing something on a lab-configured UNIX box anyway.
 
Let's not use the timer for this at all.
If you want to measure how quickly a form opens, put the following in the form's Open event. Add a couple of unbound controls to work with. You can remove them later:

Me.SaveStart = Now()

Then In the Activate event event:

Me.SaveEnd = Now()
Me.TimeDif = datediff("s", Me.SaveStart, Me.SaveEnd)

That gives you the time in seconds.

Keep in mind that the entire recordset is not necessarily loaded at that time. You should never bring down entire tables anyway. You should have a RecordSource query that selects ONLY the rows/columns the user wants to see immediately.
 
If you are interested, see my article comparing different methods of timing events. Some methods are more reliable than others

I've also done a series of speed comparison tests which may give you further ideas:
 
Let's not use the timer for this at all.
If you want to measure how quickly a form opens, put the following in the form's Open event. Add a couple of unbound controls to work with. You can remove them later:

Me.SaveStart = Now()

Then In the Activate event event:

Me.SaveEnd = Now()
Me.TimeDif = datediff("s", Me.SaveStart, Me.SaveEnd)

That gives you the time in seconds.

Keep in mind that the entire recordset is not necessarily loaded at that time. You should never bring down entire tables anyway. You should have a RecordSource query that selects ONLY the rows/columns the user wants to see immediately.
Thanks
(y)
 

Users who are viewing this thread

Back
Top Bottom