<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>extreme frame rate drop</title>
		<link>http://www.allegro.cc/forums/view/589548</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 22 Jan 2007 16:12:31 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So I&#39;m started using openlayer and one of the first things I wanted to do Is check my framerate, when I just did this : 
</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="k1">int</span> main<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td> <span class="c">// step 1 : setup the sytems     </span></td></tr><tr><td class="number">4</td><td>   setup<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td> <span class="c">// step 2 : load stuff</span></td></tr><tr><td class="number">6</td><td>   TextRenderer arial <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_font" target="_blank"><span class="a">load_font</span></a><span class="k2">(</span><span class="s">"Fonts/Arial.ttf"</span>,<span class="n">10</span>,<span class="n">15</span>,Rgba::WHITE<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td> <span class="c">// actual game loop    </span></td></tr><tr><td class="number">8</td><td>  <span class="k1">while</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">9</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">10</td><td> <span class="c">// start counting fps  </span></td></tr><tr><td class="number">11</td><td>    FpsCounter::NewFrameStarted<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td><span class="c">// fill screen   </span></td></tr><tr><td class="number">13</td><td>    Canvas::Fill<span class="k2">(</span> Rgba::BLUE <span class="k2">)</span><span class="k2">;</span> </td></tr><tr><td class="number">14</td><td><span class="c">// print fps    </span></td></tr><tr><td class="number">15</td><td>    <span class="k1">float</span> fps <span class="k3">=</span> FpsCounter::GetFps<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> </td></tr><tr><td class="number">16</td><td>    string frame_string <span class="k3">=</span> <span class="s">"FPS : "</span><span class="k3">+</span>ToString<span class="k2">(</span>fps<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>    arial.Print<span class="k2">(</span>frame_string,<span class="n">20</span>,<span class="n">20</span> <span class="k2">)</span><span class="k2">;</span> </td></tr><tr><td class="number">18</td><td> <span class="c">// Refresh the contents of the active canvas // </span></td></tr><tr><td class="number">19</td><td>    Canvas::Refresh<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>  <span class="k2">}</span>  </td></tr><tr><td class="number">21</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>
I got an average framerate of about 470 </p><p>then I decided that it would be better to make a print fps function for the sake of keeping my main loop tight. <br />the function looks like this : 
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> print_fps<span class="k2">(</span>TextRenderer var<span class="k2">)</span>
<span class="k2">{</span>  
  <span class="k1">float</span> fps <span class="k3">=</span> FpsCounter::GetFps<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> 
  string frame_string <span class="k3">=</span> <span class="s">"FPS : "</span><span class="k3">+</span>ToString<span class="k2">(</span>fps<span class="k2">)</span><span class="k2">;</span>
  var.Print<span class="k2">(</span>frame_string,<span class="n">20</span>,<span class="n">20</span> <span class="k2">)</span><span class="k2">;</span> 
<span class="k2">}</span>
</pre></div></div><p>
and in my main I replaced the old code by print_fps(arial); </p><p>these actions downed my framerate from 470 to 37 fps average? <br />I know I must be doing something wrong but I have no clue what.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sylvarant)</author>
		<pubDate>Sat, 13 Jan 2007 19:43:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Shouldn&#39;t it be like this?
</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="k1">int</span> main<span class="k2">(</span><span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td> <span class="c">// step 1 : setup the sytems     </span></td></tr><tr><td class="number">4</td><td>   setup<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">5</td><td> <span class="c">// step 2 : load stuff</span></td></tr><tr><td class="number">6</td><td>   TextRenderer arial <span class="k3">=</span> <a href="http://www.allegro.cc/manual/load_font" target="_blank"><span class="a">load_font</span></a><span class="k2">(</span><span class="s">"Fonts/Arial.ttf"</span>,<span class="n">10</span>,<span class="n">15</span>,Rgba::WHITE<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td> <span class="c">// actual game loop</span></td></tr><tr><td class="number">8</td><td>  </td></tr><tr><td class="number">9</td><td>  FpsCounter::Start<span class="k2">(</span><span class="n">85</span><span class="k2">)</span><span class="k2">;</span> <span class="c">//or other value</span></td></tr><tr><td class="number">10</td><td>  </td></tr><tr><td class="number">11</td><td>  <span class="k1">while</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/keypressed" target="_blank"><span class="a">keypressed</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">12</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">13</td><td> <span class="c">// start counting fps  </span></td></tr><tr><td class="number">14</td><td>    FpsCounter::NewFrameStarted<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td><span class="c">// fill screen   </span></td></tr><tr><td class="number">16</td><td>    Canvas::Fill<span class="k2">(</span> Rgba::BLUE <span class="k2">)</span><span class="k2">;</span> </td></tr><tr><td class="number">17</td><td><span class="c">// print fps    </span></td></tr><tr><td class="number">18</td><td>    <span class="k1">float</span> fps <span class="k3">=</span> FpsCounter::GetFps<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> </td></tr><tr><td class="number">19</td><td>    string frame_string <span class="k3">=</span> <span class="s">"FPS : "</span><span class="k3">+</span>ToString<span class="k2">(</span>fps<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>    arial.Print<span class="k2">(</span>frame_string,<span class="n">20</span>,<span class="n">20</span> <span class="k2">)</span><span class="k2">;</span> </td></tr><tr><td class="number">21</td><td> <span class="c">// Refresh the contents of the active canvas // </span></td></tr><tr><td class="number">22</td><td>    Canvas::Refresh<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td><span class="k2">}</span>  </td></tr><tr><td class="number">24</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>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CursedTyrant)</author>
		<pubDate>Sat, 13 Jan 2007 20:12:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>FPS doesn&#39;t change linearly with added scene complexity. How low does your FPS drop when you call the print_fps function two or more times?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Sat, 13 Jan 2007 20:13:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@cursedtyrant<br />I already do that in the setup function : 
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> setup<span class="k2">(</span><span class="k2">)</span> 
<span class="k2">{</span> 
  <span class="c">// Sets up the devices needed</span>
  Setup::SetupProgram<span class="k2">(</span><span class="k1">true</span>, <span class="k1">false</span>, <span class="k1">true</span><span class="k2">)</span><span class="k2">;</span>
  <span class="c">// Sets up the screen dimensions  </span>
  Setup::SetupScreen<span class="k2">(</span><span class="n">480</span>,<span class="n">320</span>,WINDOWED<span class="k2">)</span><span class="k2">;</span>    
  <a href="http://www.allegro.cc/manual/set_window_title" target="_blank"><span class="a">set_window_title</span></a><span class="k2">(</span><span class="s">"Project - Metroid Version 0.1"</span><span class="k2">)</span><span class="k2">;</span>
  <span class="c">// Set up the delta time routines with the default fps of 100.0 //</span>
  FpsCounter::Start<span class="k2">(</span> <span class="n">100</span>.<span class="n">0</span> <span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p> <br />@HOHO <br />it drops to 22.71 <img src="http://www.allegro.cc/forums/smileys/sad.gif" alt=":(" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sylvarant)</author>
		<pubDate>Sat, 13 Jan 2007 20:15:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you have an AMD Dual core 64 bit ??
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ariesnl)</author>
		<pubDate>Sat, 13 Jan 2007 21:49:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>
Comment out each line in the print_fps function and see how each line affects the FPS.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Richard Phipps)</author>
		<pubDate>Sat, 13 Jan 2007 21:57:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have an AMD Dual core 64 bit. dose it have something to do with the fps. I had some similar problem to what this person is having.<br />edit:<br />i would like to know what the amd could be at fault i notes that the the allegro cpu split dose not work as well on my cpu as it dose on a Intel single core of higher Mhz
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (piccolo)</author>
		<pubDate>Sun, 14 Jan 2007 00:14:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have a AMD Dual core 64 bit processor.And I had speed/ timing/framerate problems with my own games and with professional games.<br />A few days ago I read an artickle about this  it&#39;s a problem with timing (timestamps) and AMD Dual cores..</p><p>You should install AMD&#39;s <a href="http://www.amd.com/us-en/Processors/TechnicalResources/0,,30_182_871_9706,00.html">Dual Core Optimizer</a>!!!</p><p>It fixed everything for me and al games run a lot smoother with much higher and more stable FPS
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ariesnl)</author>
		<pubDate>Sun, 14 Jan 2007 00:33:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
A few days ago I read an artickle about this it&#39;s a problem with timing (timestamps) and AMD Dual cores..
</p></div></div><p>Actually it should be a problem with XP, not specifically with AMD (or Intel) dualcores.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Sun, 14 Jan 2007 01:07:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It had something to do with correcting the timing for the fact you have 2 processors.</p><p>but that optimizer is a true gem.. Oblivion runs like a dream now <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ariesnl)</author>
		<pubDate>Sun, 14 Jan 2007 01:20:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Ariesnl: said:</div><div class="quote"><p>
 Do you have an AMD Dual core 64 bit ??
</p></div></div><p> <br />no I&#39;m using an Intel pentium 4 .<br />what makes this really strange is the fact I&#39;ve never had these problems in allegro.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sylvarant)</author>
		<pubDate>Sun, 14 Jan 2007 01:40:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
what makes this really strange is the fact I&#39;ve never had these problems in allegro.
</p></div></div><p>Allegro and OpenLayer have little in common in this respect.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kauhiz)</author>
		<pubDate>Sun, 14 Jan 2007 01:46:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try this...</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> print_fps<span class="k2">(</span>TextRenderer <span class="k3">*</span>var<span class="k2">)</span>
<span class="k2">{</span>  
  <span class="k1">float</span> fps <span class="k3">=</span> FpsCounter::GetFps<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> 
  string frame_string <span class="k3">=</span> <span class="s">"FPS : "</span><span class="k3">+</span>ToString<span class="k2">(</span>fps<span class="k2">)</span><span class="k2">;</span>
  var-&gt;Print<span class="k2">(</span>frame_string,<span class="n">20</span>,<span class="n">20</span> <span class="k2">)</span><span class="k2">;</span> 
<span class="k2">}</span>
</pre></div></div><p>

And call the routine with:</p><p><span class="source-code">print_fps<span class="k2">(</span><span class="k3">&amp;</span>arial<span class="k2">)</span><span class="k2">;</span></span></p><p>Just a wild guess, but it couldn&#39;t hurt.</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>Sun, 14 Jan 2007 01:54:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="source-code snippet"><div class="inner"><pre><span class="c">// or by reference :P</span>
<span class="k1">void</span> print_fps<span class="k2">(</span>TextRenderer<span class="k3">&amp;</span> renderer<span class="k2">)</span>
<span class="k2">{</span>  
  <span class="k1">float</span> fps <span class="k3">=</span> FpsCounter::GetFps<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> 
  string frame_string <span class="k3">=</span> <span class="s">"FPS : "</span> <span class="k3">+</span> ToString<span class="k2">(</span>fps<span class="k2">)</span><span class="k2">;</span>
  renderer.Print<span class="k2">(</span>frame_string, <span class="n">20</span>, <span class="n">20</span><span class="k2">)</span><span class="k2">;</span> 
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (monkeyCode)</author>
		<pubDate>Sun, 14 Jan 2007 11:34:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>thanks for the link i&#39;m going to try it out now.</p><p>when i had a fps problem it was because i did not completely separate the update from the drawing</p><p>edit:<br /> did you get it fixed i only get 170 max fps on my game i need more.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (piccolo)</author>
		<pubDate>Sat, 20 Jan 2007 20:12:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
i need more.
</p></div></div><p>With what HW and how many details? I wouldn&#39;t worry about speed bofore betatesting and when it is too slow with all the details. With empty gameworld any kind of benchmarking is meaningless
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Sat, 20 Jan 2007 22:42:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>i want it to run faster on slower computers im thinks that my main cpu load is the tile animation and layers world 100*100 32bit tile. 4 layers
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (piccolo)</author>
		<pubDate>Sun, 21 Jan 2007 08:33:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You think or you profiled? Never <i>ever</i> think <i>anything</i>. Profile!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Sun, 21 Jan 2007 15:31:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You think or you profiled? Never ever think anything. Profile!
</p></div></div><p>


Assumption is the mother of all <span class="cuss"><span>fuck</span></span>ups <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ariesnl)</author>
		<pubDate>Mon, 22 Jan 2007 14: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>
void print_fps(TextRenderer&amp; renderer)<br />{  <br />  float fps = FpsCounter::GetFps(); <br />  string frame_string = &quot;FPS : &quot; + ToString(fps);<br />  renderer.Print(frame_string, 20, 20); <br />}
</p></div></div><p>
Yeah, use a reference (or a pointer) to a TextRenderer, otherwise it&#39;ll regenerate all the character images and reload them to the video memory every frame... 
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I already do that in the setup function
</p></div></div><p>
I&#39;d recommend starting the FpsCounter right before the game loop, or otherwise it&#39;ll think that the first frame takes a long time to render and adjusts itself accordingly... Which means that you&#39;ll get a hiccup at the start of the game if you use the delta time.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fladimir da Gorf)</author>
		<pubDate>Mon, 22 Jan 2007 16:12:31 +0000</pubDate>
	</item>
</rss>
