High Resolution Timer Class

When testing your code, it is a good idea to time the various routines to identify and eliminate any bottlenecks. VBA includes two functions that can be used as timers:

□ The Now function returns the current time and has a resolution of about one second.

□ The Timer function returns the number of milliseconds since midnight, with a resolution of approximately 10 milliseconds.

Neither of these are accurate enough to time VBA routines, unless the routine is repeated many times.

Modern PCs include a high-resolution timer, which updates many thousands of times per second, accessible through API calls. You can wrap these calls in a class module to provide easy access to a highresolution timer.

0 0

Post a comment