Post

 Resources 

Console


RE: I DON'T NEED FAST SPEED! Just an answer to my. Adam Hoult (0 replies, 0 views) (2000-Aug-19)
-
Well it depends on how you look at it. Essentially, a do/loop in itself is faster than a timer (as far as the actual processing goes of the loop/timer itself, not whats inside it). However a timer has to fire events, which then get added to the windows message queue. The main problem is that, timer events are very low priority in the message queue, and are often dropped to the bottom of the queue while other relatively simple tasks are given priority. For this reason, timers are Inaccurate, and because the addition to the message queue, the adding of the event, the checking of the event etc, is very processor intensive (if it was happening as quick as a do/loop that is) where as a do/loop is essentially just a JMP back to the beginning of the execution block. So in short, Timers are MORE cpu intensive than Do/Loops and also not accurate in the slightest. It's not true that the timer is so inaccurate because it has a lot to do (in fact it probably only takes < 1ms to add /check the event firing) but it's inaccurate, because it's based on a non-accurate timing system. If you want accurate timing, you should use the Performance Hardware on almost any system since the Pentium 1 (i.e QueryPerformanceFrequency etc) this is EXTREMELY accurate. Of course, both are negligable, and normally the choice only comes down to how accurate you want to be, not how cpu intensive the actual Do/Loop or Timer is. Put it this way, a Do/Loop is at the most 4 cpu cycles (3 for the check to see if it should exit the loop (depending on how complex your test is), and 1 for the JMP back) wheras a Timer can be several hundred by the time the Timer message has reached the top of the message queue. The choice is yours. Adam Sysop


-
Up One Level | Back to Forum


Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.
There have been 21 visitors within the last 20 minutes
RSS News Feed