<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Resolution of Allegro timers?</title>
		<link>http://www.allegro.cc/forums/view/592781</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 17 Aug 2007 18:40:16 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If a setup a timer to tick 1000 times a second, does it actually tick at this rate?  Is it guaranteed to give 1000 ticks per second?  Will the timer update more than one time per tick?  Like in the code below, will tick_counter++ be 1000 before an update and 1020 afterward?</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> updateTickCounter<span class="k2">(</span><span class="k2">)</span>  <span class="k2">{</span>
    tick_counter<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nonnus29)</author>
		<pubDate>Fri, 17 Aug 2007 06:01:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>IIRC Windows forces the timers to around 120 ticks a second, so that&#39;s the maximum resolution you&#39;ll get from an Allegro timer under that platform. Anything above that results in multiple scans per tick (so at 240Hz you&#39;d get two scans per tick).</p><p>I haven&#39;t done any serious testing because I&#39;ve never run into a reason to set a timer above 120Hz.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sirocco)</author>
		<pubDate>Fri, 17 Aug 2007 06:34:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Under Windows, on both <i>really</i> old and new systems, I&#39;ve had Allegro timers going at rates of 10,000 BPS with no problems. Allegro uses the Windows high-performance timers when possible, (which is practically true for all systems), however, Allegro&#39;s timers update at their own rate, so if they fall behind they have to catch up, which means the accuracy of the timer will be at the mercy of how often Allegro updates.</p><p>IE: If you have a 10,000 BPS timer, but Allegro is only updating its timers once every hundredth second, your timer will update 100 times every hundredth second. Like this:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// TimerTick runs at 10,000 BPS</span>
<span class="k1">void</span> TimerTick <span class="k2">(</span><span class="k1">void</span><span class="k2">)</span>
<span class="k2">{</span>
    timer_count<span class="k3">+</span><span class="k3">+</span><span class="k2">;</span>
<span class="k2">}</span>

<span class="c">// Time 0.000, Timer Count = 0  , Should Be = 0</span>
<span class="c">// Time 0.005, Timer Count = 0  , Should Be = 50</span>
<span class="c">// Time 0.010, Timer Count = 100, Should Be = 100</span>
<span class="c">// Time 0.015, Timer Count = 100, Should Be = 150</span>
<span class="c">// Time 0.020, Timer Count = 200, Should Be = 200</span>
</pre></div></div><p>

If you want extreme precision, you&#39;ll need to access the Windows high-performance timers yourself. In the interim though, using an Allegro timer set to something high works well enough though and I&#39;ve never encountered problems as such. You&#39;ll never be able to perceive this accuracy error unless you&#39;re trying to vsync to a 120 Hz CRT monitor signal or something.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Fri, 17 Aug 2007 08:54:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Resolution of Allegro timers?
</p></div></div><p>
Bad.</p><p>Try<br /><a href="http://www.allegro.cc/forums/search?keywords=collection+of+timer+code">http://www.allegro.cc/forums/search?keywords=collection+of+timer+code</a><br />or something.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ImLeftFooted)</author>
		<pubDate>Fri, 17 Aug 2007 09:14:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m consistantly getting resolution of about 4 milliseconds ie a timer set to 1000 BPS ticks a minmum of 4 times so I guess that means it updates 250 beats a second.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (nonnus29)</author>
		<pubDate>Fri, 17 Aug 2007 15:56:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t quote me on this, but I think that number is not only dependent on the specific computer, but also on how much stuff is running at a time and the priority of every thread that currently exists.</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Fri, 17 Aug 2007 17:16:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Last time I checked, the allegro timer maxed at about 100  bps. I made a wrapper back then which uses QPC if available, and allegro timers otherwise. It&#39;s not hard.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 17 Aug 2007 18:40:16 +0000</pubDate>
	</item>
</rss>
