[AccessD] uSecond timing

Gustav Brock gustav at cactus.dk
Thu Sep 3 06:46:58 CDT 2020


Hi Stuart

True. Apart from timing queries (often in seconds where even milliseconds are irrelevant), it is repeated code that is interesting.

However, I just time from start of the loop to the end and divide by the loop count - exactly as you did for your assembler example in your other post. Often 1000 isn't enough, then I use 1 mio. or more to obtain a time longer than a second.
That's how I measured the execution time (about 1µs) of my rounding functions:

https://github.com/GustavBrock/VBA.Round#general-rounding

Of course, you may wish to measure single steps within a larger loop, but then even microsecond timing is enough, and you will have to use alternative methods.

/gustav

-----Oprindelig meddelelse-----
Fra: AccessD <accessd-bounces at databaseadvisors.com> På vegne af Stuart McLachlan
Sendt: 3. september 2020 13:30
Til: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Emne: Re: [AccessD] uSecond timing

He mkes a good point for tat code.

A classic case where a Class is NOT the answer. (Sorry john :) )

The overhead of a classlike that compared to just wrapping the function in a couple of API calls will severely affect the accuracy of the timing process.


But that quote misses the point of using a high resoution timer.  It's when you need to repeat 
a set of instructions (either a function or just a piece of code)  many times that it matters.

Optimising parsing of lines of data read into a database from a large file with many records 
would be a prime example where it could be useful



On 3 Sep 2020 at 7:45, Gustav Brock via AccessD wrote:

> Hi John and Stuart
> 
> Here:
>  https://stackoverflow.com/a/199480/3527297
> 
> I noticed this comment, and - for most practical purposes - I think he
> has a point:
> 
> <quote>
> Still, if you're measuring performance in VBA, getting 1/100th of a
> second resolution is not bad. -- Invoking the timing calls alone could
> take a couple of ms. If the call is so fast that you need that much
> resolution to time it, you probably don't need performance data about
> that call. - BrainSlugs83 </quote>
> 
> /gustav
> 
> -----Oprindelig meddelelse-----
> Fra: AccessD <accessd-bounces at databaseadvisors.com> På vegne af Stuart
> McLachlan Sendt: 2. september 2020 23:31 Til: Access Developers
> discussion and problem solving <accessd at databaseadvisors.com> Emne:
> Re: [AccessD] uSecond timing
> 
> LongLong only works with 64bit VBA.  A lot of people are still using
> 32bit Office.
> 
> An alternative:using a UDT LongInteger
> 
> https://stackoverflow.com/questions/198409/how-do-you-test-running-tim
> e-of-vba-code 



More information about the AccessD mailing list