<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>rest(1) 65 fps!?</title>
		<link>http://www.allegro.cc/forums/view/590761</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 02 Apr 2007 20:01:34 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok.. when i use rest(1) my game fps drops to 65(64)! in both double and triple buffering. i searched the forums and found an abandoned thread about this, so lets get on with this unfinished business!</p><p>heres the thread: <a href="http://allegro.cc/forums/thread/585737">http://allegro.cc/forums/thread/585737</a> </p><p>i have no memory of this problem at home (i&#39;m in school now).</p><p>i don&#39;t know what to say so... i&#39;ll let you do the talking.</p><p><img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Wed, 28 Mar 2007 16:38:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What happens if you do rest(0)?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Wed, 28 Mar 2007 16:43:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is 65FPS too little?<br />What is the CPU usage?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Wed, 28 Mar 2007 16:44:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What is the FPS otherwise?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Peitz)</author>
		<pubDate>Wed, 28 Mar 2007 16:47:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>rest(0) acts the same as no rest(x) at all.</p><p>&quot;Is 65 FPS too little?&quot;</p><p>yeah, without rest(1) the fps is almost 600 in double buffering.<br />with rest(1) 64..</p><p>i don&#39;t have time to test triple buffering, i&#39;ll post a result as soon as i get home.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Wed, 28 Mar 2007 16:59:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
yeah, without rest(1) the fps is almost 600 in double buffering.
</p></div></div><p>I didn&#39;t ask how fast it is without the rest, I asked if it is too slow to be playable. There is a difference. </p><p>I wouldn&#39;t worry about speed unless your program runs unplayably slowly with the final graphics and effects. Trying to optimize stuff that runs at several hundred FPS is just not a waste of time.</p><p>My guess is that rest(1) uses the OS thread schedular granuality, on Windows that should be around 15-16ms. On Linux it can be from 1-10ms. That means every time you call rest with &gt;0 parameter you will rest at minimum the it takes the OS to do a context switch.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Wed, 28 Mar 2007 17:09:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
yeah, without rest(1) the fps is almost 600 in double buffering.<br /> with rest(1) 64..
</p></div></div><p>
Perhaps your FPS will stay at around 65 even if you add another million things to render per loop.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Wed, 28 Mar 2007 17:10:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
rest(0) acts the same as no rest(x) at all
</p></div></div><p>
I thought if you limited your logic and drawing to a certain framerate, rest(0) would make sure your program didn&#39;t use 100% CPU time. At least I think it was like that at one point...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (miran)</author>
		<pubDate>Wed, 28 Mar 2007 17:14:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, rest(0) give processor back to other process if they need it. If not, you will keep eating the CPU.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Wed, 28 Mar 2007 17:22:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve tinkered around with this lately.</p><p>First off, rest(1) shouldn&#39;t have <i>that</i> huge of a difference on your fps.  I was running my game at 90fps (average), added rest(1), and it went to 89fps (average).  Thus, you probably have rest(1) at a weird spot.  I only do rest(1) when I&#39;m ahead, like so (writing code from memory):</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="c">// system_time is incremented by the hardware interrupt</span></td></tr><tr><td class="number">2</td><td><span class="k1">void</span> play_game<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">3</td><td><span class="k2">{</span></td></tr><tr><td class="number">4</td><td>   <span class="k1">while</span><span class="k2">(</span><span class="k3">!</span>quit<span class="k2">)</span></td></tr><tr><td class="number">5</td><td>   <span class="k2">{</span></td></tr><tr><td class="number">6</td><td>      <span class="k1">while</span><span class="k2">(</span>system_time <span class="k3">&gt;</span> <span class="n">0</span><span class="k2">)</span></td></tr><tr><td class="number">7</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">8</td><td>          update_logic<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>          system_time--<span class="k2">;</span></td></tr><tr><td class="number">10</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td>      draw_game<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>      <span class="k1">if</span><span class="k2">(</span>system_time <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> </td></tr><tr><td class="number">14</td><td>          <a href="http://www.allegro.cc/manual/rest" target="_blank"><span class="a">rest</span></a><span class="k2">(</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>   <span class="k2">}</span></td></tr><tr><td class="number">16</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

If perhaps you put the rest(1) in the function used as the hardware interrupt, yeah, fps is going to suffer significantly.  </p><p>My program seems to be pretty intensive, rest(0) seems to give nothing back to the PC, rest(1) a smidget, and rest(10) gives a decent amount, although makes the game lag somewhat.</p><p>[edit]<br />Also, 65fps is not a bad number!  600 is ridiculous, your monitor can&#39;t even draw that much.  Throw in a vsync and you&#39;ll see a more realistic number.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Wed, 28 Mar 2007 20:14:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>&#39;An average 17&quot; monitor can reach 85 Hz, meaning that any performance reached by the game over 85 fps is discarded.&#39; - <a href="http://en.wikipedia.org/wiki/Frame_rate">Source</a></p><p>I&#39;m no video expert, but I&#39;ve always thought that 60 fps was great. According to that same article, Rockstar&#39;s GTA games are limited to 25-30 fps. How fast can the average human process an image anyway? 600 fps is insane! There&#39;s no point consuming cycles with your game if it doesn&#39;t need them.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Wed, 28 Mar 2007 23:50:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How fast can the average human process an image anyway?
</p></div></div><p>Highly depending on what kind of changes there are between sequental images. In cinema you see 11FPS movie and think it is nice and fluid. At home you or at least some people can separate individual frames in FPS running at &gt;50FPS
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Thu, 29 Mar 2007 00:31:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How fast can the average human process an image anyway?
</p></div></div><p>
<a href="http://www.askaninja.com/news/2006/06/02/ask-a-ninja-special-delivery-6-ninja-and-the-matrix">A ninja can see 7000+.</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Onewing)</author>
		<pubDate>Thu, 29 Mar 2007 00:36:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">HoHo said:</div><div class="quote"><p>
In cinema you see 11FPS movie and think it is nice and fluid.
</p></div></div><p>
I doubt you would, actually. Unless you added so much blur you&#39;d think the projector operator was legally blind.</p><div class="quote_container"><div class="title">bamccaig said:</div><div class="quote"><p>
How fast can the average human process an image anyway?
</p></div></div><p>
<a href="http://amo.net/NT/02-21-01FPS.html">A whole lot.</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Thu, 29 Mar 2007 00:40:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>ok.. sorry for the delay.. anyway:</p><p>double buffering | windowed | rest(0) | using vsync        =   75 fps (correct)<br />double buffering | windowed | rest(0) | without vsync      =   125 fps (unsure)</p><p>double buffering | fullscreen | rest(0) | using vsync      =   75 fps (correct)<br />double buffering | fullscreen | rest(0) | without vsync      =   155 fps (unsure)</p><p>double buffering | windowed | rest(1) | using vsync        =   75 fps (correct)<br />double buffering | windowed | rest(1) | without vsync        =   112 fps (unsure)</p><p>double buffering | fullscreen | rest(1) | using vsync        =   75 fps (correct)<br />double buffering | fullscreen | rest(1) | without vsync        =   135 fps (unsure)</p><p>triple buffering | rest(0)      =   64-70 fps (??)<br />triple buffering | rest(1)      =   75 fps (correct)</p><p>hmm, i don&#39;t think there&#39;s anything wrong here.. but then again it wasn&#39;t on this computer i discovered it.</p><p>the only thing i can think of now is: why does my computer get 1/4 fps in un-v-sync:ed double buffering of the computer in school? as far as i can tell, my computer is far superior..</p><p>i&#39;m going to school tomorrow morning and take some tests there.. i remember the monitors refresh rate where 85, but i could get past 64 in some cases.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Thu, 29 Mar 2007 00:46:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Albin, I have the same result as you for my game. If I don&#39;t use rest(x), it&#39;s around 350fps. If I put in a rest(1), it drops to 64fps. The game runs at 64fps no matter how much I push around the screen, so I&#39;m not that bothered by it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Thu, 29 Mar 2007 01:09:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey, what&#39;s the matter with those FPS, unless it drops bellow 30, there&#39;s no need to worry. Movie is ussually shot at 24 FPS. Even if you have Quake 3 running at 15 FPS, you&#39;re not likely to see the actual frames. Besides 600 is evil, it eats 100% of CPU and therefore consume my battery on laptop.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (OICW)</author>
		<pubDate>Thu, 29 Mar 2007 01:19:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I doubt you would, actually. Unless you added so much blur you&#39;d think the projector operator was legally blind.
</p></div></div><p>I wonder where I heard about 11FPS, it should be around 18FPS actually. Sorry about the confusion.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
i&#39;m going to school tomorrow morning and take some tests there..
</p></div></div><p>Please measure the CPU usage also. If it is less than 50% you can stop further measurements and <b>start writing the game!</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Thu, 29 Mar 2007 01:23:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>People always want to have the quickest thing even when it is not needed.</p><p>Example: <br />For those who have a car, we admit it can easily reach 180 km/h. Do you even drive a whole travel at this speed ? No. That the same with your FPS. Even if it can reach the light speed, it is not needed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 29 Mar 2007 01:24:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That the same with your FPS. Even if it can reach the light speed...
</p></div></div><p>
Light speed fps? Now, that&#39;s my kinda computer. Imagine the amount of processing, computations and graphics you could push through that baby. Windows might <i>just</i> work at a reasonable speed on it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Thu, 29 Mar 2007 02:44:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>HardTranceFan: ...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Thu, 29 Mar 2007 02:52:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">HardTranceFan said:</div><div class="quote"><p>
Albin, I have the same result as you for my game. If I don&#39;t use rest(x), it&#39;s around 350fps. If I put in a rest(1), it drops to 64fps. The game runs at 64fps no matter how much I push around the screen, so I&#39;m not that bothered by it.
</p></div></div><p> but it&#39;s not right? :S that enough is reason.</p><div class="quote_container"><div class="title">OICW said:</div><div class="quote"><p>
Hey, what&#39;s the matter with those FPS, unless it drops bellow 30, there&#39;s no need to worry. Movie is ussually shot at 24 FPS. Even if you have Quake 3 running at 15 FPS, you&#39;re not likely to see the actual frames. Besides 600 is evil, it eats 100% of CPU and therefore consume my battery on laptop.
</p></div></div><p> 15 fps.... that&#39;s overkill.. - -, it&#39;s not about &#39;seeing&#39; the frames, it&#39;s about the feeling of smoothness.</p><div class="quote_container"><div class="title">HoHo said:</div><div class="quote"><p>
Please measure the CPU usage also. If it is less than 50% you can stop further measurements and start writing the game!
</p></div></div><p> haha, that&#39;s what i want to do too.. but every time i start to &quot;make a game&quot; it ends because i know of a better way to do it - -. it just isn&#39;t fun to write code when the rest of the code sucks.. i have a scrapyard with about 600 files and 127 folders, and that&#39;s after i&#39;ve cleaned it up..</p><div class="quote_container"><div class="title">GullRaDriel said:</div><div class="quote"><p>
People always want to have the quickest thing even when it is not needed.
</p></div></div><p> that&#39;s NOT my case.. and the difference between X fps and X+ fps is visible! ok, &quot;can&#39;t&quot; see the frames, but thats the point, isn&#39;t it? the higher fps the smoother the movements, that&#39;s not a theory, it&#39;s a fact! i absolutely don&#39;t want a fps higher than what the monitor can display.</p><p>and 64 sucks!! if i have a monitor able to do 120(mine does 75) why would i want 64?? and for the second time: it IS visible. i don&#39;t understand why people can&#39;t see it..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Thu, 29 Mar 2007 02:59:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
but it&#39;s not right?
</p></div></div><p>Why it isn&#39;t? You can&#39;t make meaningful decisions only based on FPS without looking at what the CPU does. In your and OICW&#39;s case it is probably idling most of the time and that is a good thing.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Thu, 29 Mar 2007 03:08:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>nm
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Thu, 29 Mar 2007 03:11:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Time to clear up some things:</p><p>If you put rest(1) in your game loop, it will burn 1 ms of processor time per frame, giving it back to the CPU. Thus the absolute maximum framerate possible would be 1000 fps, assuming your loop did practically nothing besides rest(1). If you&#39;re getting a <i>huge</i> framerate drop by adding rest(1), then you&#39;re probably adding it in the wrong spot and it&#39;s being called <i>more than once</i> per frame. To know for certain if it&#39;s working properly you need to make an empty loop that calls rest(1) a certain number of times, then compare that with an Allegro timer to see if the two are running the same speed. If not, I&#39;m willing to bet that Allegro programs aren&#39;t the only ones having timing problems on your system.</p><p>Also consider that framerate drops exponentially for the amount of processing you&#39;re doing. For instance, if your game logic uses 5 ms of processor time, you would have a framerate of 200 FPS. If it uses 10 ms, 100 FPS. 20 ms, 50 FPS. 40 ms, 25 FPS. As you&#39;ll see, it doesn&#39;t take much extra to kill the framerate.</p><p>If you&#39;re not going to use rest(1) you <i>must</i> at least use rest(0), or else your game will not give any CPU time back to the system and background processes may stop working properly. Using rest(1) over rest(0) isn&#39;t necessary, but increases I/O compatability in Allegro 4.1.0 or higher under older Windows OSes. (Which is why <b>I</b> use it.)</p><p>Be careful where you put the rest() commands. Do not put them immediately before a vsync() or triple buffering command, do not put them inside an acquire/release pair, do not put them in your timer routines and be certain they&#39;re only being called <u>once</u> per frame. (Leave rest() commands out of loops that may repeat more than once per frame.)</p><p>If you&#39;re still having doubts, set up your rest() commands to be called less often than the framerate. (For instance, call rest(1) every four frames or so.) This <i>might</i> still work as intended, but I&#39;ve never tried it (yet) so I can&#39;t guarantee it will.</p><p>Lastly, about framerates: The Human brain can distinguish individual frames up to around 24 FPS. After that, the brain no longer sees each frame, but motion. That <i>does not</i> mean the brain can&#39;t figure out higher framerates, it just means that the brain stops being able to perceive each individual frame. The point at which framerates become indistinguishable varies with each person. For me, it&#39;s around the 100 FPS mark. Movies run at around 24 FPS. Thus if you&#39;re making a game using a real-time game engine, don&#39;t worry about the framerate being only 60-something: Not too many people will be able to tell and even fewer will care.</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>Thu, 29 Mar 2007 16:58:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you&#39;re not going to use rest(1) you must at least use rest(0), or else your game will not give any CPU time back to the system and background processes may stop working properly.
</p></div></div><p>
Not really, but it&#39;s the Right Thing to do. Under any multitasking OS you would need to worry about, the OS will make sure other processes get some processor time. Calling rest(0) just tells the OS &quot;Hey, if anything&#39;s waiting for the CPU, let &#39;em have it, but give it back to me when they&#39;re done.&quot; instead of waiting for the OS to &quot;forcefully&quot; take the CPU back. Calling rest(1), on the other hand, tells the OS &quot;I don&#39;t need the CPU right now. Do whatever you want with it but give it back to me ASAP after 1 millisecond.&quot;</p><p>And note that timer granularity may not be all that high. Even if you call rest(1), it&#39;s likely to be about 5 to 10 ms before it gets back to you. The actual time it takes is based on many small inconceiveable details, and is for all intents and purposes, random within a 10 ms range.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Thu, 29 Mar 2007 17:12:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">HoHo said:</div><div class="quote"><p>
Why it isn&#39;t? You can&#39;t make meaningful decisions only based on FPS without looking at what the CPU does. In your and OICW&#39;s case it is probably idling most of the time and that is a good thing.
</p></div></div><p> if it&#39;s not supposed to be that way it&#39;s wrong :/.. wrong wrong wrong!</p><div class="quote_container"><div class="title">HardTranceFan said:</div><div class="quote"><p>
nm
</p></div></div><p> que?</p><div class="quote_container"><div class="title">Kris Asick said:</div><div class="quote"><p>
Time to clear up some things:</p><p>If you put rest(1) in your game loop, it will burn 1 ms of processor time per frame, giving it back to the CPU. Thus the absolute maximum framerate possible would be 1000 fps, assuming your loop did practically nothing besides rest(1). If you&#39;re getting a huge framerate drop by adding rest(1), then you&#39;re probably adding it in the wrong spot and it&#39;s being called more than once per frame. To know for certain if it&#39;s working properly you need to make an empty loop that calls rest(1) a certain number of times, then compare that with an Allegro timer to see if the two are running the same speed. If not, I&#39;m willing to bet that Allegro programs aren&#39;t the only ones having timing problems on your system.</p><p>Also consider that framerate drops exponentially for the amount of processing you&#39;re doing. For instance, if your game logic uses 5 ms of processor time, you would have a framerate of 200 FPS. If it uses 10 ms, 100 FPS. 20 ms, 50 FPS. 40 ms, 25 FPS. As you&#39;ll see, it doesn&#39;t take much extra to kill the framerate.</p><p>If you&#39;re not going to use rest(1) you must at least use rest(0), or else your game will not give any CPU time back to the system and background processes may stop working properly. Using rest(1) over rest(0) isn&#39;t necessary, but increases I/O compatability in Allegro 4.1.0 or higher under older Windows OSes. (Which is why <b>I</b> use it.)</p><p>Be careful where you put the rest() commands. Do not put them immediately before a vsync() or triple buffering command, do not put them inside an acquire/release pair, do not put them in your timer routines and be certain they&#39;re only being called once per frame. (Leave rest() commands out of loops that may repeat more than once per frame.)</p><p>If you&#39;re still having doubts, set up your rest() commands to be called less often than the framerate. (For instance, call rest(1) every four frames or so.) This might still work as intended, but I&#39;ve never tried it (yet) so I can&#39;t guarantee it will.</p><p>Lastly, about framerates: The Human brain can distinguish individual frames up to around 24 FPS. After that, the brain no longer sees each frame, but motion. That does not mean the brain can&#39;t figure out higher framerates, it just means that the brain stops being able to perceive each individual frame. The point at which framerates become indistinguishable varies with each person. For me, it&#39;s around the 100 FPS mark. Movies run at around 24 FPS. Thus if you&#39;re making a game using a real-time game engine, don&#39;t worry about the framerate being only 60-something: Not too many people will be able to tell and even fewer will care.
</p></div></div><p> i&#39;m pretty sure i&#39;m not calling rest(x) more than one time per frame.. i have now changed the resolution from 640x480 to 320x240 due to  <br />the cpu working it&#39;s <span class="cuss"><span>ass</span></span> of drawing fullscreen pictures.. thats not really the reason.. i just like really low resolution or very high resolution.. although i love 640x480, 320x240 is cooler - -, and the cpu doesn&#39;t even need to breath to draw..<br />-<br />thanks.</p><div class="quote_container"><div class="title">Kitty Cat said:</div><div class="quote"><p>
Even if you call rest(1), it&#39;s likely to be about 5 to 10 ms before it gets back to you
</p></div></div><p> that&#39;s outrageous!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Thu, 29 Mar 2007 18:05:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
if it&#39;s not supposed to be that way it&#39;s wrong :/.. wrong wrong wrong!
</p></div></div><p>Say what?</p><p>As I said before, stop worrying about performance. As long as it works fast enough to be bareable to develop on your machine it is good enough. Once the game is ready then start optimizing. Optimizing before that will be meaningless for two reasons:<br />1) There is a good chance you will replace the optimized piece of code with something else since it doesn&#39;t do what you want<br />2) you won&#39;t finish the game anyway and wasting time optimizing it will only slow your progress down
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Thu, 29 Mar 2007 18:15:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>that may be right.. i think i&#39;m going to make something now, something small that is..
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Thu, 29 Mar 2007 18:39:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">GullRaDriel said:</div><div class="quote"><p>
For those who have a car, we admit it can easily reach 180 km/h. Do you even drive a whole travel at this speed ? No. That the same with your FPS. Even if it can reach the light speed, it is not needed.
</p></div></div><p>

The speed that a car can travel is generally determined by the engine&#39;s output power. More power is required to climb a hill or pull a trailer, or even when there is more cargo or persons inside. In order to perform adequately when the car is put under it&#39;s maximum load there needs to be enough power (and torque) for it to satisfy these requirements. Conversely, when the car is at it&#39;s minimum load, it resultantly has extra power and torque that it doesn&#39;t need (though some of us will take advantage anyway). <i>{must-fight-urge-to-smiley}</i></p><p>Some vehicles do have restriction mechanisms that either limit the RPMs, the top speed, or a combination of variables to prevent the car from actually reaching it&#39;s potential.</p><p>You don&#39;t cruise around at 100 MPH, but not because speed is bad: only because it would be unsafe in today&#39;s traffic model (some people can&#39;t drive safely doing 40 Km/h); humans simply can&#39;t react quickly enough to do stop and go driving from 0-180-0, stop-light to stop-light; and it would exhaust resources faster than necessary (and as a result cost a whole lot more). We don&#39;t need to get to the grocery store in 30 seconds. We can wait that 5 minutes: especially when compared to not making it at all.</p><p>As far as a game&#39;s FPS, you need to keep in mind that you&#39;re sharing resources with the system. It would be great if we could reliably achieve astronomical frame rates, but you also don&#39;t need 600 FPS to run smoothly. Still though, I would look into why there is such a major difference. Also how are you counting fps?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Thu, 29 Mar 2007 19:12:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You cannot physically get a higher FPS than what your monitor vsync is set to. Keep that in mind. So if your monitor is set to 85 Hz (a common setting), every frame above those 85 you render per second is a waste of cpu time (and energy) - you will never see it. It doesn&#39;t make your game any smoother; if you think it does, go see a brain surgeon or a shrink.<br />600 fps equals a frame render time of 1.6 ms, 64 fps is 15.6 ms. The same speed decrease (14 ms) applied AGAIN will result in ~33 fps - still playable, and also unlikely, since the rest() statement obviously adds 14 msecs of idling to your main loop. Really, you have nothing to worry about. I&#39;d love to see the main loop though, I&#39;m pretty sure the rest(1) is in an obscure place, or you&#39;re doing some very unorthodox frame buffering.</p><p>Oh, and on the car analogy:<br />1. I know some people who do cruise at 180 km/h for hours; in Germany, this is even legal.<br />2. The top speed of a car is determined by a number of factors, output power being only one of them. The faster you go, the more important aerodynamics become. Apart from that, car engines perform best in a quite small RPM window, so the gear layout also has crucial impact on the car&#39;s top speed - if the top gear can&#39;t keep the engine inside the window, then you can&#39;t accelerate easily, even if in theory you have the engine power.<br />3. Even with zero reaction time, today&#39;s engines cannot accelerate a car from 0 to 180 km/h between two traffic lights in typical urban conditions.<br />4. I walk to the grocery store.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Thu, 29 Mar 2007 20:13:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="k2">{</span>
  <span class="k1">while</span><span class="k2">(</span>momo&gt;0<span class="k2">)</span>
  <span class="k2">{</span>
  momo--<span class="k2">;</span>
  <span class="s">"looped"</span><span class="k3">-</span>logic<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k2">}</span>
  
  fps-rate-logic<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
    
  graphics<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/rest" target="_blank"><span class="a">rest</span></a><span class="k2">(</span>x<span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p> the code does not look like this of course..</p><p>also... if this&quot;You cannot physically get a higher FPS than what your monitor vsync is set to. Keep that in mind.&quot; was somewhat directed to me i just want to inform you that i&#39;m well aware of that..</p><p>&quot;since the rest() statement obviously adds 14 msecs of idling to your main loop&quot; thats creepy... isn&#39;t there a better way to do &quot;resting&quot;?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Thu, 29 Mar 2007 22:24:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
the code does not look like this of course..
</p></div></div><p>
Then what does it look like?<br />Try to post an example of actual code that shows the behaviour you describe, and we&#39;ll see what it does and why.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
also... if this&quot;You cannot physically get a higher FPS than what your monitor vsync is set to. Keep that in mind.&quot; was somewhat directed to me
</p></div></div><p>
Yes it was...
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
i just want to inform you that i&#39;m well aware of that..
</p></div></div><p>
Then why do you want 600 fps?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
&quot;since the rest() statement obviously adds 14 msecs of idling to your main loop&quot; thats creepy... isn&#39;t there a better way to do &quot;resting&quot;?
</p></div></div><p>
No, not really. You could use OS-specific thread management, but I suspect that it might interfere with what allegro does thread-wise, and it&#39;s definitely not cross-platform.<br />OTOH, if a single rest(1) statement causes the average frame time to rise by 14 ms, then something is wrong. Either with your computer, or with your code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Thu, 29 Mar 2007 22:42:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><b>Kitty Cat:</b> You&#39;re right in one regard, multi-tasking operating systems will generally be fine without a rest() statement to give time back... not <i>all</i> computer hardware will be however. I have one story of a person who&#39;s computer would overheat when running an older version of PixelShips that didn&#39;t have rest() statements in it. I personally have had issues with some 3D programs (using another game library) that didn&#39;t include equivalent statements. There will always be the rogue hardware configuration that needs to be explicitly told that it can have some CPU time back for other processes and I really don&#39;t know why, just that it can happen.</p><p>The moral: Always give some CPU time up. Don&#39;t hog it.</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, 30 Mar 2007 00:46:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Tobias Dammers said:</div><div class="quote"><p>
Then what does it look like?
</p></div></div><p> i think someone wanted to know how my main routine looked like?..</p><div class="quote_container"><div class="title">Tobias Dammers said:</div><div class="quote"><p>
Then why do you want 600 fps?
</p></div></div><p> When did i say i wanted 600 fps!? - - i want at least as much as the monitor can display.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Albin Engström)</author>
		<pubDate>Fri, 30 Mar 2007 03:35:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Tobias Dammers said:</div><div class="quote"><p>
I know some people who do cruise at 180 km/h for hours; in Germany, this is even legal.
</p></div></div><p>

The only place you could possibly &quot;cruise&quot; doing 180 Km/h for hours is on a large highway or freeway. The German autobahn, for example. That&#39;s not even really related to stop-and-go traffic, where it&#39;s not feasible. On top of that, the resources burned doing 180 Km/h for hours would be enough to notice compared to cruising at the &quot;recommended&quot; 130 Km/h.</p><p>If you enjoy driving and speed than you might enjoy the 180. I probably fit this model (in fact, if my car could do more I probably would at times). Others that are conservative would probably not want to burn the extra fuel. You know, like Europeans.</p><p> <i>Don&#39;t bother <span class="cuss"><span>bitch</span></span>ing that you&#39;re European and speed or whatever... The majority of cars in Europe are small and lack high performance so you&#39;re automatically trapt in your continent&#39;s conservativeness!

Besides, I&#39;m only kidding. Germany makes cool cars. Italy makes semi-cool cars. It&#39;s the other countries that suck.</i>
</p><div class="quote_container"><div class="title">Tobias Dammers said:</div><div class="quote"><p>
The top speed of a car is determined by a number of factors, output power being only one of them. The faster you go, the more important aerodynamics become. Apart from that, car engines perform best in a quite small RPM window, so the gear layout also has crucial impact on the car&#39;s top speed - if the top gear can&#39;t keep the engine inside the window, then you can&#39;t accelerate easily, even if in theory you have the engine power.
</p></div></div><p>

Absolutely. There are other factors as well that limit top speed such as weather and road conditions, however, the engine&#39;s power output is where it all begins. The other factors are where the power is lost along the chain.</p><p>Also, acceleration is derived from torque, not power. If the engine remained at the same speed and the gear ratio remained the same (and all other variables remained constant) your speed and acceleration wouldn&#39;t change so there&#39;s no point leaving the engine in that window.</p><p>The real strategy is designing the engine and drive train to maximize power and torque curves, at the rear wheels (or the <span class="cuss"><span>bitch</span></span> front wheels or both), while the car is designed to be as aerodynamic as possible (without sacrificing style) to minimize loss.</p><div class="quote_container"><div class="title">Tobias Dammers said:</div><div class="quote"><p>
Even with zero reaction time, today&#39;s engines cannot accelerate a car from 0 to 180 km/h between two traffic lights in typical urban conditions.
</p></div></div><p>

There aren&#39;t ANY urban conditions where my car can get from 0-180-0 between stoplights. In fact, my car tops out at 175.</p><div class="quote_container"><div class="title">bamccaig said:</div><div class="quote"><p>
...because it would be unsafe in today&#39;s traffic model (some people can&#39;t drive safely doing 40 Km/h); humans simply can&#39;t react quickly enough to do stop and go driving from 0-180-0, stop-light to stop-light; and it would exhaust resources faster than necessary (and as a result cost a whole lot more).
</p></div></div><p>

Perhaps you missed that part?</p><p>Even if it was feasible for cars to do 0-180-0 from stop-light to stop-light, the human brain couldn&#39;t process it fast enough so there&#39;s no point developing the technology - at least not until computers drive.</p><div class="quote_container"><div class="title">Albin Engström said:</div><div class="quote"><p>
When did i say i wanted 600 fps!? - - i want at least as much as the monitor can display.
</p></div></div><p>

Technically, I don&#39;t think you did, however, you did ask if 65 was too little. I think Tobias was just making it clear that 600 is tooooooo much.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Fri, 30 Mar 2007 03:50:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
</p><div class="quote_container"><div class="title">I said:</div><div class="quote"><p>

nm
</p></div></div><p>
que?
</p></div></div><p>
nm = never mind. I wrote something, and later decided it was irrelevant and so I removed the contents of my post.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Fri, 30 Mar 2007 05:13:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
i think someone wanted to know how my main routine looked like?..
</p></div></div><p>
I meant something that actually compiles.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you enjoy driving and speed than you might enjoy the 180. I probably fit this model (in fact, if my car could do more I probably would at times). Others that are conservative would probably not want to burn the extra fuel. You know, like Europeans.
</p></div></div><p>
Funny you should say that.<br />Over here, it&#39;s the conservative folks who would do 180 in spite of the extra fuel.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Don&#39;t bother ing that you&#39;re European and speed or whatever... The majority of cars in Europe are small and lack high <br />performance so you&#39;re automatically trapt in your continent&#39;s conservativeness!
</p></div></div><p>
Conservative people, at least in Europe, insist on driving huge smelly cars, while we dirty communists use public transport or bicycles, and sometimes we even walk.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Besides, I&#39;m only kidding. Germany makes cool cars. Italy makes semi-cool cars. It&#39;s the other countries that suck.
</p></div></div><p>
I don&#39;t really share your opinion here.<br />The last car I owned cost me 1400 €, and it took me wherever I needed to go, at reasonable speed (it could easily go 120 km/h, the general speed limit in the Netherlands). What would be the point in buying a car that costs 20 times that amount, would use more fuel, and were harder to park? Only that it looks cooler? Plus I&#39;d spend all night worrying if my precious car were OK? Hmmm... I think I know better ways to spend my money.<br />Also, an Audi TT doesn&#39;t look THAT cool while almost touching my rear bumper, which expensive German cars somehow tend to do.<br />Also, a general speed limit makes sense; somewhere around 120-140 km/h, the danger involved simply outweighs the convenience of getting there a bit faster.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 30 Mar 2007 13:49:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Tobias said:</div><div class="quote"><p>
(...) if a single rest(1) statement causes the average frame time to rise by 14 ms, then something is wrong. Either with your computer, or with your code. (...)
</p></div></div><p>
If this is an effect of the granularity of the Windows scheduler, there&#39;s no programmer fault. It&#39;s very dependent on the actual OS version, and most of the information I could find on the web is for NT or 2000 versions, unfortunately.</p><p>Anyway, it&#39;s difficult to profile performance on a multi-tasking OS.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Fri, 30 Mar 2007 14:35:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>But the granularity issue shouldn&#39;t cause an AVERAGE delay of 14 ms, but rather an OCCASIONAL one. Calling rest(1) a thousand times should still result in a delay of 1 second plus 1000 * the overhead for calling rest().</p><p>OTOH, it might still just be that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 30 Mar 2007 15:57:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t have Allegro installed at work, can anyone do a quick test to see if it really is so?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Fri, 30 Mar 2007 16:36:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What is currently in test:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#include &lt;nilorea.h&gt;</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td>FILE <span class="k3">*</span>out<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td><span class="k1">int</span> it <span class="k3">=</span> <span class="n">1</span> ,  </td></tr><tr><td class="number">6</td><td>    var <span class="k3">=</span> <span class="n">0</span> , </td></tr><tr><td class="number">7</td><td>    elapsed_time <span class="k3">=</span> <span class="n">0</span> , </td></tr><tr><td class="number">8</td><td>    med_time <span class="k3">=</span> <span class="n">0</span> ,</td></tr><tr><td class="number">9</td><td>  rest_time <span class="k3">=</span> <span class="n">1</span> ,</td></tr><tr><td class="number">10</td><td>  min <span class="k3">=</span> <span class="k3">-</span><span class="n">1</span>,</td></tr><tr><td class="number">11</td><td>  max <span class="k3">=</span> <span class="k3">-</span><span class="n">1</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>  </td></tr><tr><td class="number">13</td><td>N_TIME high_p_time <span class="k2">;</span> </td></tr><tr><td class="number">14</td><td>&#160;</td></tr><tr><td class="number">15</td><td><span class="k1">int</span> main<span class="k2">(</span> <span class="k1">int</span> argc , <span class="k1">char</span> <span class="k3">*</span>argv<span class="k2">[</span><span class="k2">]</span> <span class="k2">)</span></td></tr><tr><td class="number">16</td><td><span class="k2">{</span></td></tr><tr><td class="number">17</td><td>&#160;</td></tr><tr><td class="number">18</td><td>  <span class="k1">if</span><span class="k2">(</span> argc <span class="k3">&gt;</span> <span class="n">1</span> <span class="k2">)</span></td></tr><tr><td class="number">19</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">20</td><td>    <span class="k1">if</span><span class="k2">(</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_741.html" target="_blank">sscanf</a><span class="k2">(</span> argv<span class="k2">[</span> <span class="n">1</span> <span class="k2">]</span> , <span class="s">"%d"</span> , <span class="k3">&amp;</span>it <span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span> <span class="k2">)</span></td></tr><tr><td class="number">21</td><td>        it <span class="k3">=</span> <span class="n">1</span> <span class="k2">;</span></td></tr><tr><td class="number">22</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">23</td><td>  </td></tr><tr><td class="number">24</td><td>  <span class="k1">if</span><span class="k2">(</span> argc <span class="k3">&gt;</span> <span class="n">2</span> <span class="k2">)</span></td></tr><tr><td class="number">25</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">26</td><td>    <span class="k1">if</span><span class="k2">(</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_741.html" target="_blank">sscanf</a><span class="k2">(</span> argv<span class="k2">[</span> <span class="n">2</span> <span class="k2">]</span> , <span class="s">"%d"</span> , <span class="k3">&amp;</span>rest_time <span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span> <span class="k2">)</span></td></tr><tr><td class="number">27</td><td>        rest_time <span class="k3">=</span> <span class="n">1</span> <span class="k2">;</span></td></tr><tr><td class="number">28</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">29</td><td>  </td></tr><tr><td class="number">30</td><td>  </td></tr><tr><td class="number">31</td><td>  <a href="http://www.allegro.cc/manual/allegro_init" target="_blank"><span class="a">allegro_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">32</td><td>  <a href="http://www.allegro.cc/manual/install_timer" target="_blank"><span class="a">install_timer</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">33</td><td>  </td></tr><tr><td class="number">34</td><td>  out <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_337.html" target="_blank">fopen</a><span class="k2">(</span> <span class="s">"result.txt"</span> , <span class="s">"a+"</span> <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">35</td><td>  </td></tr><tr><td class="number">36</td><td>  <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span> out , <span class="s">"Testing rest( %d ) %d times\n"</span> , rest_time , it <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">37</td><td>  </td></tr><tr><td class="number">38</td><td>  <span class="k1">for</span><span class="k2">(</span> var <span class="k3">=</span> <span class="n">0</span> <span class="k2">;</span> var <span class="k3">&lt;</span> it <span class="k2">;</span> var <span class="k3">+</span><span class="k3">+</span> <span class="k2">)</span></td></tr><tr><td class="number">39</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">40</td><td>  </td></tr><tr><td class="number">41</td><td>    start_HiTimer<span class="k2">(</span> <span class="k3">&amp;</span>high_p_time <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">42</td><td>    </td></tr><tr><td class="number">43</td><td>    <a href="http://www.allegro.cc/manual/rest" target="_blank"><span class="a">rest</span></a><span class="k2">(</span> rest_time <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">44</td><td>    </td></tr><tr><td class="number">45</td><td>    elapsed_time <span class="k3">=</span> get_usec<span class="k2">(</span> <span class="k3">&amp;</span>high_p_time <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">46</td><td>    </td></tr><tr><td class="number">47</td><td>    med_time <span class="k3">+</span><span class="k3">=</span> elapsed_time <span class="k2">;</span></td></tr><tr><td class="number">48</td><td>    </td></tr><tr><td class="number">49</td><td>    <span class="k1">if</span><span class="k2">(</span> min <span class="k3">=</span><span class="k3">=</span> <span class="k3">-</span><span class="n">1</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> max <span class="k3">=</span><span class="k3">=</span> <span class="k3">-</span><span class="n">1</span> <span class="k2">)</span></td></tr><tr><td class="number">50</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">51</td><td>      max <span class="k3">=</span> elapsed_time <span class="k2">;</span></td></tr><tr><td class="number">52</td><td>      min <span class="k3">=</span> max <span class="k2">;</span></td></tr><tr><td class="number">53</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">54</td><td>    </td></tr><tr><td class="number">55</td><td>    <span class="k1">if</span><span class="k2">(</span> elapsed_time <span class="k3">&gt;</span> max <span class="k2">)</span></td></tr><tr><td class="number">56</td><td>      max <span class="k3">=</span> elapsed_time<span class="k2">;</span></td></tr><tr><td class="number">57</td><td>    <span class="k1">if</span><span class="k2">(</span> elapsed_time <span class="k3">&lt;</span> min <span class="k2">)</span></td></tr><tr><td class="number">58</td><td>      min <span class="k3">=</span> elapsed_time<span class="k2">;</span></td></tr><tr><td class="number">59</td><td>  </td></tr><tr><td class="number">60</td><td>    <span class="k1">if</span><span class="k2">(</span> argc <span class="k3">&lt;</span> <span class="n">4</span> <span class="k2">)</span></td></tr><tr><td class="number">61</td><td>      <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span> out , <span class="s">"Iteration %d : %d usec , %d min , %d max \n"</span> , var , elapsed_time , min , max <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">62</td><td>  </td></tr><tr><td class="number">63</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">64</td><td>  </td></tr><tr><td class="number">65</td><td>  med_time <span class="k3">=</span> med_time <span class="k3">/</span> it <span class="k2">;</span></td></tr><tr><td class="number">66</td><td>  </td></tr><tr><td class="number">67</td><td>  <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span> out , <span class="s">"Med_time : %d usec , min: %d , max: %d\n\n"</span> , med_time , min , max <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">68</td><td>  </td></tr><tr><td class="number">69</td><td>  <a href="http://www.delorie.com/djgpp/doc/libc/libc_308.html" target="_blank">fclose</a><span class="k2">(</span> out <span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">70</td><td>  </td></tr><tr><td class="number">71</td><td>  <a href="http://www.allegro.cc/manual/allegro_exit" target="_blank"><span class="a">allegro_exit</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">72</td><td>  </td></tr><tr><td class="number">73</td><td>  <span class="k1">return</span> TRUE<span class="k2">;</span></td></tr><tr><td class="number">74</td><td>  </td></tr><tr><td class="number">75</td><td><span class="k2">}</span><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span></td></tr></tbody></table></div></div><p>

The <a href="http://www.allegro.cc/files/attachment/591719">results</a> tells:</p><p>*Testing rest( 0 ) 1000 times<br /> Med_time : 6 usec , min: 2 , max: 505</p><p>*Testing rest( 1 ) 1000 times<br /> Med_time : 1984 usec , min: 1081 , max: 14009</p><p>*Testing rest( 10 ) 1000 times<br /> Med_time : 10876 usec , min: 9818 , max: 22332</p><p>Here we are. </p><p>EDIT: Fixed min for displaying a wrong value, changing file opening to a+ , currently timing 100000 times for significant values. Will edit another time to attach the results.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Mon, 02 Apr 2007 14:26:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
But the granularity issue shouldn&#39;t cause an AVERAGE delay of 14 ms, but rather an OCCASIONAL one. Calling rest(1) a thousand times should still result in a delay of 1 second plus 1000 * the overhead for calling rest().
</p></div></div><p>Calling rest(1) a thousand times should result in a delay of (1 + overhead + GRANULARITY/2)*1000 ms at best.  Because you have to wait your overhead, then your 1 ms, then the time it takes for the scheduler to come around again, which is on average half the granularity.</p><p>(In practice I think it could be worse than that because the sleep()-type queries in an OS tend to be specified as &quot;sleep AT LEAST this long&quot; with no particular upper bound, so if they have to wake a whole bunch of processes up at once they can still keep the scheduler running in constant time by waking only one process per interrupt.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Zaphos)</author>
		<pubDate>Mon, 02 Apr 2007 15:59:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>GullRaDriel: Those max values look really weird. One time you called rest(1) and it waited for 14 seconds? That doesn&#39;t make any sense!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ron Ofir)</author>
		<pubDate>Mon, 02 Apr 2007 17:38:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
One time you called rest(1) and it waited for 14 seconds?
</p></div></div><p> μsec!=msec.</p><p>Though μsec aka microsecond is 1/1000,000&#39;th of a second, not 1/10,000&#39;th
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Mon, 02 Apr 2007 17:46:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Testing from 0 to 10 millisecond said:</div><div class="quote"><p>

Testing rest( 0 ) 100000 times<br />Med_time : 4 usec , min: 2 , max: 4927</p><p>Testing rest( 1 ) 100000 times<br />Med_time : 2083 usec , min: 988 , max: 25731</p><p>Testing rest( 2 ) 100000 times<br />Med_time : 3019 usec , min: 1970 , max: 18255</p><p>Testing rest( 3 ) 100000 times<br />Med_time : 4057 usec , min: 2952 , max: 28395</p><p>Testing rest( 4 ) 100000 times<br />Med_time : 4986 usec , min: 3922 , max: 23558</p><p>Testing rest( 5 ) 100000 times<br />Med_time : 5956 usec , min: 4909 , max: 24927</p><p>Testing rest( 6 ) 100000 times<br />Med_time : 6943 usec , min: 5888 , max: 23677</p><p>Testing rest( 7 ) 100000 times<br />Med_time : 7918 usec , min: 6862 , max: 24174</p><p>Testing rest( 8 ) 100000 times<br />Med_time : 8888 usec , min: 7842 , max: 28967</p><p>Testing rest( 9 ) 100000 times<br />Med_time : 9780 usec , min: 8814 , max: 22391</p><p>Testing rest( 10 ) 100000 times<br />Med_time : 10746 usec , min: 9795 , max: 19646
</p></div></div><p>

All times are microseconds, not millisecond or second.</p><p>i.e: When it says max: 23677 it means that it has wait for 23.677 milliseconds.</p><p>All those results gave us the following picture:<br /> <span class="remote-thumbnail"><span class="json">{"name":"591727","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/1\/01c695fd33c10887dd9e063afdaab1b1.jpg","w":979,"h":461,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/1\/01c695fd33c10887dd9e063afdaab1b1"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/0/1/01c695fd33c10887dd9e063afdaab1b1-240.jpg" alt="591727" width="240" height="113" /></span></p><p>As you can see the minimum value is generally following the expected value. It is not really the case with the maximum value... </p><p>Conclusion: do not use rest for timing stuff.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Mon, 02 Apr 2007 19:39:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>As I&#39;ve said before, the only reason you&#39;d want to use rest(1) or Sleep(1) over rest(0) or Sleep(0) is to avoid issues with stalling the keyboard, mouse and joystick input. But I&#39;m working on solving that issue and I think I have a solution, but I have no idea how to program it. (Though it shouldn&#39;t take more than a couple minutes to do for someone who does know how.)</p><p>Here&#39;s a forum link to my recent post discussing the possibility of solving that issue: <a href="http://www.allegro.cc/forums/thread/590832/662625">http://www.allegro.cc/forums/thread/590832/662625</a></p><p>But it&#39;s good to know that the rest() and Sleep() statements may burn tons of time because it explains some of the framerate troubles I&#39;ve seen in my games on specific (usually lower end) systems.</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>Mon, 02 Apr 2007 19:49:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sounds like a good place for a slider in the options menu (for whatever game you are making) then.</p><p>No resting    -          Yielding     -   Resting<br />(for best performance)  (recomended)      (when you don&#39;t want to use all CPU (power saving mode))
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Mon, 02 Apr 2007 20:01:34 +0000</pubDate>
	</item>
</rss>
