|
-
Apr 28th, 2000, 07:58 AM
#1
Thread Starter
Hyperactive Member
i am sure all of u guys noticed how Slow is vbtimer
even te shortest delay 1ms is not exactly 1ms it is at least 100 ms ... anyway , what i want is a timer that can
process small intervals of the order of micro seconds
is that possible ?
-
Apr 28th, 2000, 08:04 AM
#2
I think using the GetTickCount API will work. There's an example on Fox's programming site, so find one of Fox's posts and click on his programming site.
-
Apr 28th, 2000, 08:06 AM
#3
Nevermind, here it is... 
http://foxmccloud.tsx.org
-
Apr 28th, 2000, 08:08 PM
#4
Frenzied Member
Better than that, use the QueryPerformanceCounter and QueryPerformanceFrequency API's the apiviewer declares them like this
Code:
Public Declare Function QueryPerformanceCounter Lib "kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As LARGE_INTEGER) As Long
Public Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As LARGE_INTEGER) As Long
but as usual you need to alter this slightly.
instead of large_integer use currency data types, large integers are 2 longs which makes it hard, the currency is a true Big integer data type, scaled down.
oh, I forgot to tell you how to work them
declare them like this
Code:
Public Declare Function QueryPerformanceCounter Lib "kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As Currency) As Long
Public Declare Function QueryPerformanceFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As Currency) As Long
Query performance counter will put a value into lpperformancecount reperesenting the number of counts since an arbitrary point in time, very much like get tick count but the intervals are faster. Query ferformance frequency puts a value into lpfrequency representing the number of intervals per second, because they're both scaled down you can divide to get a time interval.
Here's a code example timing a function MyFunc()
Code:
Public sub TimeFunction()
Dim curStartTime as Currency
Dim curFinishTime as Currency
Dim curTimerFreq as currency
dim dblTime as Double
QueryPerformanceCounter curStartTime
MyFunc
QueryPerformanceCounter curFinishTime
QueryPerformaceFrequency curTimerFreq
dblTime = cdbl(curfinishtime - curstarttime) / cdbl(curTimerFreq)
Msgbox "Function Takes " & cStr(dblTime) & " Seconds"
End Sub
You can convert this into a timer using the same method in Fox's site.
[Edited by Sam Finch on 04-29-2000 at 02:09 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|