View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
spilly39 spilly39 is offline
external usenet poster
 
Posts: 16
Default HOWTO Time VBA code

Hi Garry
ISTR that resolution for Timer() & Now() is far less than the ticker inside
the RTC. Does that ring a bell?
In fact writing this brings back a vague memory that 'Tick' is the right
search term for what I remember. I'll have a go...
....Found it!

The keywords are GetTickCount and/or QueryPerformanceCounter
KB Article 172338 talks v simply about the various timers and gives sample
code
Also look at the bottom post on this page
http://answers.microsoft.com/en-us/o...a-bd6d75e42bf6
There is some code you can paste into a module and it runs fine.
It has some nice random data generation in it too
The data is aimed at a rather specific problem, but the timer technique is
the bees knees

As I'm worried about inner loop performance, I think that Timer might not
get down to the resolution I wd like.

spilly

"GS" wrote in message ...
I'm not a whiz-kid (I'm in my 60s) but here's a simple way I find
useful...

Sub TimeEvents()
' use to time procedures or functions
Dim Starttime As Date, EndTime As Date
Starttime = Timer

'Run procedure

EndTime = Timer
MsgBox Format(EndTime - Starttime, "0.0000")
End Sub

Note that you can set whatever result format you want. (The format above
displays seconds to 4 decimal places.)

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc