|
-
February 11th, 2000, 02:26 AM
#1
Speed Control finer than milliseconds?
It is really possible to control the execution speed on various computers using the Sleep API. But can someone go even better than this, like nano-, picoseconds, etc. Any cheeky technique.
-
February 11th, 2000, 03:49 AM
#2
Re: Speed Control finer than milliseconds?
Don't know for sure, but the api is called with the parameter 'dwMilliseconds as Long'.
Try sending a value < 1, like 0.1
It's worth a try
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
-
February 11th, 2000, 04:25 AM
#3
Re: Speed Control finer than milliseconds?
But a 'long' is still a 'whole' number.
The CCRP project team (http://www.mvps.org/ccrp) provide a 'high-resolution' timer object that allows you to capture 1ms events, but as for any lower than that - I wouldn't have thought the average PC was upto the job.
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
February 15th, 2000, 12:14 AM
#4
Re: Speed Control finer than milliseconds?
Why shouldn't a PC do the job. There are lots and lots of MHz, i.e., millions of pulses per second...
There must be a way!
-
February 15th, 2000, 10:57 AM
#5
Re: Speed Control finer than milliseconds?
All these "sleep" to a 0.001 second...all that is crap, timers are really inaccurate, but altough SLEEP function is much more accurate then using TIMER keyword, sleep is still probably will never be "perfect". Even thought current Intel CPU can support up to 2 billion operations per sec, windows cuts that power maybe like 50%, and VB is "slow" language itself, so the result is slippery. To tell the truth, I don't like the windows by it's speed, because it's really slow and it slows down other programs, but it's easy-to-use!!! For ex. to play games over internet you don't need CABLE modem (like DSL or T1) to have optimal performance, you need it because you play games throught windows, where windows makes it really slow transfering of bytes, so it sucks!!
WINDOWS SUCKS!! (if you think from programming point of view)
-
February 15th, 2000, 11:10 AM
#6
Re: Speed Control finer than milliseconds?
The API call GetProcessTimes theoretically allows time slices to be as small as 100 nanoseconds (but no PC will allow this low a resolution that I know of).
The declarations are:
Type FILETIME
dwLowDateTime as Long
dwHighDateTime as Long
End Type
Declare Function GetProcessTimes Lib "kernel32" Alias "GetProcessTimes" (byval hProcess as Long, lpCreationTime as FILETIME, lpExitTime as FILETIME, lpKernelTime as FILETIME, lpUserTime as FILETIME) as Long
You will have to experiment to see how low a resolution you can get in practice.
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
|