Clock speed? - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: Clock speed? (/thread-9876.html) |
Clock speed? - Ralph - 01-25-2007 I was just thinking that, if a program can detect the computer speed for the computer it is running on, we could just use that value as part of our short program pauses, so that the pause time would be the same length of real time, no matter the particular speed of the computer in use. For instance, if my computer clock speed = 3GHx, I could write use it for a program, like this: Code: CLS Clock speed? - DrV - 01-25-2007 Clock speed is not really a good thing to base delays on, for various reasons, the most important being that you can't depend on your program getting the CPU all of the time (unless you're running on DOS). If you need to wait for a particular amount of real time, just check TIMER in a loop. Clock speed? - Ralph - 01-25-2007 DrV: The best I can get with TIMER is something like 0.56 or so of a second. I can't get less! I'll give it a try, though. (Pause, to give it a try) I'm back. Nope, it didn't work good enough for my lightning program, using this code: Code: T1 = 0.00000005 T1 = 0.00000005. Am I doing it right? Clock speed? - nkk_kan - 01-25-2007 But does that count clock speed? Don't u need to use an ASM Interuppt to find it out? Clock speed? - DrV - 01-25-2007 You might be interested in these articles: http://faq.qbasicnews.com/?blast=TimerTopics Clock speed? - Ralph - 01-26-2007 I tried the CLOCK function from the link in DrV's post, with the code below. My part is the "to test it:" part, where I'm trying to flash the screen to show lightning. It does a very poor job, as the timing I get seems very inconsistent! Code: DECLARE FUNCTION CLOCK& () Clock speed? - Dinosaur - 01-26-2007 Ralph The only way to use timer tick accurately is to get the interupt to update your variable each time the interupt happens. I use a scheme as below to accurately time events, without creating a lot of overhead. Code: '--------------------------------- Clock speed? - Ralph - 01-26-2007 Thanks to all that suggested different methods of obtaining the desired time delay for values much less than 1 second. As I am getting over my head, I will stay with my present method, which seems "good enough", even though far from perfect. You know, the old KISS principle, which I had forgotten to apply! |