Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » extreme frame rate drop

This thread is locked; no one can reply to it. rss feed Print
extreme frame rate drop
Sylvarant
Member #7,886
October 2006

So I'm started using openlayer and one of the first things I wanted to do Is check my framerate, when I just did this :

1int main()
2{
3 // step 1 : setup the sytems
4 setup();
5 // step 2 : load stuff
6 TextRenderer arial = load_font("Fonts/Arial.ttf",10,15,Rgba::WHITE);
7 // actual game loop
8 while(!keypressed())
9 {
10 // start counting fps
11 FpsCounter::NewFrameStarted();
12// fill screen
13 Canvas::Fill( Rgba::BLUE );
14// print fps
15 float fps = FpsCounter::GetFps();
16 string frame_string = "FPS : "+ToString(fps);
17 arial.Print(frame_string,20,20 );
18 // Refresh the contents of the active canvas //
19 Canvas::Refresh();
20 }
21}END_OF_MAIN()

I got an average framerate of about 470

then I decided that it would be better to make a print fps function for the sake of keeping my main loop tight.
the function looks like this :

void print_fps(TextRenderer var)
{  
  float fps = FpsCounter::GetFps(); 
  string frame_string = "FPS : "+ToString(fps);
  var.Print(frame_string,20,20 ); 
}

and in my main I replaced the old code by print_fps(arial);

these actions downed my framerate from 470 to 37 fps average?
I know I must be doing something wrong but I have no clue what.

CursedTyrant
Member #7,080
April 2006
avatar

Shouldn't it be like this?

1int main()
2{
3 // step 1 : setup the sytems
4 setup();
5 // step 2 : load stuff
6 TextRenderer arial = load_font("Fonts/Arial.ttf",10,15,Rgba::WHITE);
7 // actual game loop
8
9 FpsCounter::Start(85); //or other value
10
11 while(!keypressed())
12 {
13 // start counting fps
14 FpsCounter::NewFrameStarted();
15// fill screen
16 Canvas::Fill( Rgba::BLUE );
17// print fps
18 float fps = FpsCounter::GetFps();
19 string frame_string = "FPS : "+ToString(fps);
20 arial.Print(frame_string,20,20 );
21 // Refresh the contents of the active canvas //
22 Canvas::Refresh();
23}
24}END_OF_MAIN()

---------
Signature.
----
[My Website] | [My YouTube Channel]

HoHo
Member #4,534
April 2004
avatar

FPS doesn't change linearly with added scene complexity. How low does your FPS drop when you call the print_fps function two or more times?

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Sylvarant
Member #7,886
October 2006

@cursedtyrant
I already do that in the setup function :

void setup() 
{ 
  // Sets up the devices needed
  Setup::SetupProgram(true, false, true);
  // Sets up the screen dimensions  
  Setup::SetupScreen(480,320,WINDOWED);    
  set_window_title("Project - Metroid Version 0.1");
  // Set up the delta time routines with the default fps of 100.0 //
  FpsCounter::Start( 100.0 );
}


@HOHO
it drops to 22.71 :(

Ariesnl
Member #2,902
November 2002
avatar

Do you have an AMD Dual core 64 bit ??

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Richard Phipps
Member #1,632
November 2001
avatar

Comment out each line in the print_fps function and see how each line affects the FPS.

piccolo
Member #3,163
January 2003
avatar

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.
edit:
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

wow
-------------------------------
i am who you are not am i

Ariesnl
Member #2,902
November 2002
avatar

I have a AMD Dual core 64 bit processor.And I had speed/ timing/framerate problems with my own games and with professional games.
A few days ago I read an artickle about this it's a problem with timing (timestamps) and AMD Dual cores..

You should install AMD's Dual Core Optimizer!!!

It fixed everything for me and al games run a lot smoother with much higher and more stable FPS

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

HoHo
Member #4,534
April 2004
avatar

Quote:

A few days ago I read an artickle about this it's a problem with timing (timestamps) and AMD Dual cores..

Actually it should be a problem with XP, not specifically with AMD (or Intel) dualcores.

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Ariesnl
Member #2,902
November 2002
avatar

It had something to do with correcting the timing for the fact you have 2 processors.

but that optimizer is a true gem.. Oblivion runs like a dream now ;D

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Sylvarant
Member #7,886
October 2006

Ariesnl: said:

Do you have an AMD Dual core 64 bit ??


no I'm using an Intel pentium 4 .
what makes this really strange is the fact I've never had these problems in allegro.

Kauhiz
Member #4,798
July 2004

Quote:

what makes this really strange is the fact I've never had these problems in allegro.

Allegro and OpenLayer have little in common in this respect.

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

Kris Asick
Member #1,424
July 2001

Try this...

void print_fps(TextRenderer *var)
{  
  float fps = FpsCounter::GetFps(); 
  string frame_string = "FPS : "+ToString(fps);
  var->Print(frame_string,20,20 ); 
}

And call the routine with:

print_fps(&arial);

Just a wild guess, but it couldn't hurt.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

monkeyCode
Member #7,140
April 2006

// or by reference :P
void print_fps(TextRenderer& renderer)
{  
  float fps = FpsCounter::GetFps(); 
  string frame_string = "FPS : " + ToString(fps);
  renderer.Print(frame_string, 20, 20); 
}

piccolo
Member #3,163
January 2003
avatar

thanks for the link i'm going to try it out now.

when i had a fps problem it was because i did not completely separate the update from the drawing

edit:
did you get it fixed i only get 170 max fps on my game i need more.

wow
-------------------------------
i am who you are not am i

HoHo
Member #4,534
April 2004
avatar

Quote:

i need more.

With what HW and how many details? I wouldn'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

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

piccolo
Member #3,163
January 2003
avatar

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

wow
-------------------------------
i am who you are not am i

HoHo
Member #4,534
April 2004
avatar

You think or you profiled? Never ever think anything. Profile!

__________
In theory, there is no difference between theory and practice. But, in practice, there is - Jan L.A. van de Snepscheut
MMORPG's...Many Men Online Role Playing Girls - Radagar
"Is Java REALLY slower? Does STL really bloat your exes? Find out with your friendly host, HoHo, and his benchmarking machine!" - Jakub Wasilewski

Ariesnl
Member #2,902
November 2002
avatar

Quote:

You think or you profiled? Never ever think anything. Profile!

Assumption is the mother of all fuckups ;)

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)
Current project: [Star Trek Project ] Join if you want ;-)

Fladimir da Gorf
Member #1,565
October 2001
avatar

Quote:

void print_fps(TextRenderer& renderer)
{
float fps = FpsCounter::GetFps();
string frame_string = "FPS : " + ToString(fps);
renderer.Print(frame_string, 20, 20);
}

Yeah, use a reference (or a pointer) to a TextRenderer, otherwise it'll regenerate all the character images and reload them to the video memory every frame...

Quote:

I already do that in the setup function

I'd recommend starting the FpsCounter right before the game loop, or otherwise it'll think that the first frame takes a long time to render and adjusts itself accordingly... Which means that you'll get a hiccup at the start of the game if you use the delta time.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Go to: