Timer Function Accuracy 
Author Message
 Timer Function Accuracy

Hello,
I am trying to use the Timer function to measure the interval between 2
events in a single process app.  Is there a way to reliably determine the
accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

Thanks,
Chuck



Sun, 23 Mar 2003 09:58:01 GMT  
 Timer Function Accuracy
In my experience I have found the Timer object that VB provides to give accuracy to around 0ms to +50ms.
That is
if you set the timer to 200ms it could trigger anywhere between 200ms and 250ms although most of the time
unless the timer is set to below 50ms it is usually accurate within a few ms except under heavy system
load when you could even miss events.

Jason

Quote:

> Hello,
> I am trying to use the Timer function to measure the interval between 2
> events in a single process app.  Is there a way to reliably determine the
> accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

> Thanks,
> Chuck



Sun, 23 Mar 2003 10:59:51 GMT  
 Timer Function Accuracy
Jason,
Thanks.  You were referring to the Timer Control (and not the Timer
function), right? Do you think the same holds true for the Timer function?

Thanks,
Chuck


Quote:
> In my experience I have found the Timer object that VB provides to give

accuracy to around 0ms to +50ms.
Quote:
> That is
> if you set the timer to 200ms it could trigger anywhere between 200ms and

250ms although most of the time
Quote:
> unless the timer is set to below 50ms it is usually accurate within a few

ms except under heavy system
Quote:
> load when you could even miss events.

> Jason


> > Hello,
> > I am trying to use the Timer function to measure the interval between 2
> > events in a single process app.  Is there a way to reliably determine
the
> > accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

> > Thanks,
> > Chuck



Sun, 23 Mar 2003 11:41:02 GMT  
 Timer Function Accuracy
Hi Chuck

Use this to time your event

Declare Function timeGetTime Lib "winmm" () As Long

This returns a Long which which represents the number of milli-seconds
Windows has been running.

regards

Ian

** invalid email address, change dk to denmark

homepage http://www.kingsoft-denmark.com/
Tips & Tricks page http://tips.kingsoft-denmark.com/


Quote:
> Hello,
> I am trying to use the Timer function to measure the interval between 2
> events in a single process app.  Is there a way to reliably determine the
> accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

> Thanks,
> Chuck



Sun, 23 Mar 2003 14:47:31 GMT  
 Timer Function Accuracy
Hi!
Use of QueryPerformanceFrequency and QueryPerformanceCounter gives the
best results for Your task
Good luck
Quote:

> Hello,
> I am trying to use the Timer function to measure the interval between 2
> events in a single process app.  Is there a way to reliably determine the
> accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

> Thanks,
> Chuck



Wed, 18 Jun 1902 08:00:00 GMT  
 Timer Function Accuracy
Chuck,

in a new project, use the following code:

===================================
Option Explicit

Dim mStartTime As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
    Caption = "Mouse-button is down"
    mStartTime = Timer
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y
As Single)
Dim StopTime As Single
    StopTime = Timer
    Caption = "Mouse-button was down for " & StopTime - mStartTime & "
seconds"
End Sub
===================================

It gives me an elapsed time with the accuracy if a single (7 positions).

Johan.



| Hello,
| I am trying to use the Timer function to measure the interval between 2
| events in a single process app.  Is there a way to reliably determine the
| accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?
|
| Thanks,
| Chuck
|
|



Wed, 18 Jun 1902 08:00:00 GMT  
 Timer Function Accuracy


Wed, 18 Jun 1902 08:00:00 GMT  
 Timer Function Accuracy
Thanks again.

I am trying to implement QueryPerformanceFrequency  and
QueryPerformanceCounter as function, but am having a few problems.

1) When I try to paste in the declaration (from API Viewer in VB6), my VB
environment wants to drop some of the code.  For example, the original is --

Private Declare Function QueryPerformanceFrequency Lib "kernel32" Alias
"QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long

But it gets truncated to --

Private Declare Function QueryPerformanceFrequency Lib "kernel32"
(lpFrequency As LARGE_INTEGER) As Long

Is there a way to avoid this?

I keep getting User-Defined Type not Defined

2) Do I need to make a copy of the kernel32 file to somewhere in the VB
environment?

Thanks,
Chuck


Quote:
> Hi!
> Use of QueryPerformanceFrequency and QueryPerformanceCounter gives the
> best results for Your task
> Good luck


> > Hello,
> > I am trying to use the Timer function to measure the interval between 2
> > events in a single process app.  Is there a way to reliably determine
the
> > accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

> > Thanks,
> > Chuck



Wed, 18 Jun 1902 08:00:00 GMT  
 Timer Function Accuracy
Answer to my own question --

Change LARGE_INTEGER  to Long and it worked. Didn't need the 'Alias' part
either.

Chuck


Quote:
> Thanks again.

> I am trying to implement QueryPerformanceFrequency  and
> QueryPerformanceCounter as function, but am having a few problems.

> 1) When I try to paste in the declaration (from API Viewer in VB6), my VB
> environment wants to drop some of the code.  For example, the original
is --

> Private Declare Function QueryPerformanceFrequency Lib "kernel32" Alias
> "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long

> But it gets truncated to --

> Private Declare Function QueryPerformanceFrequency Lib "kernel32"
> (lpFrequency As LARGE_INTEGER) As Long

> Is there a way to avoid this?

> I keep getting User-Defined Type not Defined

> 2) Do I need to make a copy of the kernel32 file to somewhere in the VB
> environment?

> Thanks,
> Chuck



> > Hi!
> > Use of QueryPerformanceFrequency and QueryPerformanceCounter gives the
> > best results for Your task
> > Good luck


> > > Hello,
> > > I am trying to use the Timer function to measure the interval between
2
> > > events in a single process app.  Is there a way to reliably determine
> the
> > > accuracy of this interval? Ie can I count on 3 decimal places? 2 ? 1?

> > > Thanks,
> > > Chuck



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Timer, accuracy in millisecs!

2. vb timer accuracy ???

3. Timer Accuracy - Help !

4. Accuracy of Timers in VB5

5. Timer with high accuracy

6. Timer Accuracy

7. Wanted: VB3 Timer with millisecond accuracy.

8. Timer accuracy??? -RFH ( Request for Help)

9. timer accuracy of mmsystem.dll

10. Accuracy of timers in VB?

11. Timer accuracy

12. Timer accuracy

 

 
Powered by phpBB® Forum Software