jwcolby
jwcolby at colbyconsulting.com
Tue Feb 10 23:22:04 CST 2009
Stuart, My understanding of the 10 ms deal is simply that each time slice allocated by the OS (pre-emptive multitasker) is 10 ms. The tick count is still 1 ms regardless of the time slice length, even for XP / 2K. Again my understanding is that the tick count comes off the system clock. I will admit it has been a long time since I looked at that stuff however. http://www.experts-exchange.com/Programming/Misc/Q_21889245.html Who know how accurate these "experts" are, but it SOUNDS good! ;-) John W. Colby www.ColbyConsulting.com Stuart McLachlan wrote: > JC is using the timeGetTime() API call. > > Windows95/98 has a 1ms resolution for this > W2K/XP generally have a resolution of about 10ms > My Vista machiine has a resolution of 1ms, so it looks as though MS may have fixed this. > > Note however: > - you can use the timeBeginPeriod() API call to increase the granularity in W2K/XP. > - it is a low priority call and can be delayed or even dropped if the queue is busy. > > Another problem is that it rolls over every 49 days so there is a *very* slight possibility that > the Stop time may be much smaller than the Start time. > > If your programmers want accurate time, they should be using > QueryPerformanceFrequency and QueryPerformanceCounter, using them you can get sub- > microsecond (close to nanosecond) accuracy. > > Try pasting this into a Module and see what your numbers are like. > > > <start code> > Option Explicit > > Declare Function QueryPerformanceCounter Lib "Kernel32" _ > (X As Currency) As Boolean > Declare Function QueryPerformanceFrequency Lib "Kernel32" _ > (X As Currency) As Boolean > Declare Function GetTickCount Lib "Kernel32" () As Long > Declare Function timeGetTime Lib "winmm.dll" () As Long > > Sub Test_Timers() > Dim Ctr1 As Currency, Ctr2 As Currency, Freq As Currency > Dim Count1 As Long, Count2 As Long, Loops As Long > ' > ' Time QueryPerformanceCounter > ' > If QueryPerformanceCounter(Ctr1) Then > QueryPerformanceCounter Ctr2 > Debug.Print "Start Value: "; Format$(Ctr1, "0.0000") > Debug.Print "End Value: "; Format$(Ctr2, "0.0000") > QueryPerformanceFrequency Freq > Debug.Print "QueryPerformanceCounter minimum resolution: 1/" & _ > Freq * 10000; " sec" > Debug.Print "API Overhead: "; (Ctr2 - Ctr1) / Freq; "seconds" > Else > Debug.Print "High-resolution counter not supported." > End If > ' > ' Time GetTickCount > ' > Debug.Print > Loops = 0 > Count1 = GetTickCount() > Do > Count2 = GetTickCount() > Loops = Loops + 1 > Loop Until Count1 <> Count2 > Debug.Print "GetTickCount minimum resolution: "; _ > (Count2 - Count1); "ms" > Debug.Print "Took"; Loops; "loops" > ' > ' Time timeGetTime > ' > Debug.Print > Loops = 0 > Count1 = timeGetTime() > Do > Count2 = timeGetTime() > Loops = Loops + 1 > Loop Until Count1 <> Count2 > Debug.Print "timeGetTime minimum resolution: "; _ > (Count2 - Count1); "ms" > Debug.Print "Took"; Loops; "loops" > End Sub > > <end code>