is there any method to trap an event if occuring in nanosecond .
if not atleast
1/10000 of second...?
i think timer is not good option for dealing lower than 1/1000 of second..!
Printable View
is there any method to trap an event if occuring in nanosecond .
if not atleast
1/10000 of second...?
i think timer is not good option for dealing lower than 1/1000 of second..!
The GetTickCount API is the lowest increment of time that you can use in VB.
Here is an example.
VB Code:
'In general section Private Declare Function GetTickCount& Lib "kernel32" () Private Sub Form_Load() 'KPD-Team 1998 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] 'Get the tickcount ret& = GetTickCount& MsgBox Str$(ret& / 60000) + " minutes." End Sub
ret1& = GetTickCount&
ret2& = GetTickCount&
MsgBox Str$(ret1& - ret2& )
---------------------------------
it always displays ZERO 0
but i want to get the differnece it elapsed during executing first line to second.
.....!!!!
i know it will be difficult
but i know nothing is impossible.. :mike:
Quote:
Originally Posted by vbPoet
VB Code:
Private Declare Function GetTickCount& Lib "kernel32" ()
did you add that to the top of your form?
Yeah ..
The reason this is happening is because it is the same the time in the first line as it is in the second.Quote:
Originally Posted by vbPoet
Its milliseconds i dont think you can get much more accurate than that in vb.
Whats the purpose of doing this?
Pino
Not necessarily.Quote:
Originally Posted by dglienna
Quote:
Originally Posted by Pino
You can actually get down to .10 of a millisecond using some API called QueryPerformace or something like that.
GetTickCount only updates like every 15 milliseconds or something like that.
Yes i use the query performance counter in most of my apps but i didnt know that :-/Quote:
Originally Posted by Cander
Interesting thanks :)
Wow. I don't think i've even heard of that. I'll have to keep it in my bag of tricks. :wave:
Start Value: 95052324.5422
End Value: 95052324.5444
QueryPerformanceCounter minimum resolution: 1/3579545 sec
API Overhead: 6.14603252648032E-06 seconds
GetTickCount minimum resolution: 10 ms
Took 22963 loops
timeGetTime minimum resolution: 1 ms
Took 4467 loops
Isn't that still 1 ms? Still better than GetTickCount, though!
Well whatever route you take you are going to have a problem with consistancy since you are going through different layers to get that data and other processes and factors can affect your numbers at such high precission. The most accurate would be to measure and time CPU cycles which goes way beyond the scope of VB.Quote:
Isn't that still 1 ms? Still better than GetTickCount, though!
i m again confused with ...
how can i get ... time difference b/w two statements.
-------------
it is taking LARGE INTEGER ...
highpart
lowpart
but what is the real formula to conclude the result..
thx in advance for guiding me..!
Not really... I just stopped careing :)Quote:
Originally Posted by szlamany
As Martin's link shows the most effeciant timers are multimedia timers. However they rely on your hardware (if your hardware have any MM timers at all, which all modern computers have). But you can never rely on that they will have the same high resolution on different computers. But the calls will never be slower then around 10ms which is the same resolution used by GetTickCount.
The reason the difference between two calls to GetTickCount is zero is of course because the two calls was made faster then about 10ms.
i m really trying to keep in touch with all of you guys..
because when someone asks question he is presumed to be student and other one is teacher
i respect my teachers.
i don't where m i creating problems for my teachers.
if you look into my profile my 40% threads are solved and i have marked it as nike sign...
-----------------
why i need it...?
i need it because of various reasons..
i) to check to what extent VB is accurate or reach at
ii) i m going to work on hardware interfacing project,my this knowledge will work
to choose what is better for me VB or VC
iii) it is always good to have deep knowledge..
-----
and many other reasons can be applied .....!!! :mike:
GetTickCount minimum resolution: 10 ms
Took 22963 loops
timeGetTime minimum resolution: 1 ms
Took 4467 loops
Isn't that faster ?
solved....VB Code:
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
thx for taking part
There are actually 3 timers being compared here:Quote:
Start Value: 95052324.5422
End Value: 95052324.5444
QueryPerformanceCounter minimum resolution: 1/3579545 sec
API Overhead: 6.14603252648032E-06 seconds
GetTickCount minimum resolution: 10 ms
Took 22963 loops
timeGetTime minimum resolution: 1 ms
Took 4467 loops
Isn't that still 1 ms? Still better than GetTickCount, though!
GetTickCount minimum resolution: 10 ms
timeGetTime minimum resolution: 1 ms
and
QueryPerformanceCounter minimum resolution: .0003 ms
that's 300 nanoseconds
Oh, OK Now I understand. That is a lot faster. Not just a little!
Did anyone notice that he is subtracting the end time from the start time which won't do him any good (besides not having GetTickCount not defined properly).
Should BeQuote:
ret1& = GetTickCount&
ret2& = GetTickCount&
MsgBox Str$(ret1& - ret2& )
MsgBox ret2& - ret1&
I know, I know, Silly details...