[AccessD] Timer class suggestions...

Bobby Heid bheid at appdevgrp.com
Tue May 9 10:17:16 CDT 2006


What timer are you referring to in the article?

Bobby

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, Lambert
Sent: Tuesday, May 09, 2006 10:53 AM
To: Heenan, Lambert; 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Timer class suggestions...


To answer my own question...

I added the following block of code to the article's test code...

      '
      ' Time timer
      '
        Dim sCount1 As Single, sCount2 As Single

        Debug.Print
        Loops = 0
        sCount1 = Timer()
        Do
          sCount2 = Timer()
          Loops = Loops + 1
        Loop Until sCount1 <> sCount2
        Debug.Print "timer minimum resolution: "; _
                    (sCount2 - sCount1); "ms"
        Debug.Print "Took"; Loops; "loops"

... And here is the result...

Test_Timers
Start Value: 2196010.9816
End Value: 2196010.9826
QueryPerformanceCounter minimum resolution: 1/3579545 sec
API Overhead:  2.79365114840015E-06 seconds

GetTickCount minimum resolution:  10 ms
Took 52952 loops

timeGetTime minimum resolution:  1 ms
Took 4795 loops

timer minimum resolution:  0.0078125 ms
Took 11716 loops

So Timer has about the same resolution as timeGetTime, but it runs about
twice as fast.

Lambert

-----Original Message-----
From: Heenan, Lambert 
Sent: Tuesday, May 09, 2006 10:43 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Timer class suggestions...


Hello Gustav,

As the kBase article says that GetTickCount  and TimeGetTime have ~10ms
resolution I wonder if there is anything to be gained in using them rather
that the built-in function Timer, which also has ~10ms resolution?

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, May 09, 2006 10:24 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Timer class suggestions...


Hi Bobby

Never heard of those QueryPerformance-things so I located this page:

  http://support.microsoft.com/kb/q172338

However, the info here is wrong. 
timeGetTime is certainly accurate to the millisecond, thus the most precise
of all standard timer functions. But you must specify to use a resolution of
1 ms. 

1. Insert this declaration:

Private Declare Function timeBeginPeriod Lib "winmm.dll" ( _
  ByVal uPeriod As Long) _
  As Long

2. Modify the code like this:

      '
      ' Time GetTickCount
      '
      ' Set resolution of timer to 1 ms.
        timeBeginPeriod 1
        Debug.Print
        Loops = 0
        Count1 = GetTickCount()

3. Run code:

Start Value: 9221238,3029
End Value: 9221238,3039
QueryPerformanceCounter minimum resolution: 1/3579545 sec
API Overhead:  2,79365114840015E-06 seconds

GetTickCount minimum resolution:  15 ms
Took 23289 loops

timeGetTime minimum resolution:  1 ms
Took 187 loops

As for your class I've never had extensive timer needs so I have no
comments.

/gustav





More information about the AccessD mailing list