Author Topic: [Solved] Performance Issues  (Read 1508 times)

Liaf

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
  • yay!
    • View Profile
[Solved] Performance Issues
« on: Mon, Mar 15, 2010 »
So I'm nearly done with my new Flash Game, and somehow it's lagging quite a bit (like all 10 secs it is stuck for 0.1 secs). The FPS are ALWAYS above 55. What could be the issue here? I'm compiling in release mode when I want to try out the performance, and in my code there shouldn't be too many stuff like colliding and overlap to make this happen (I did once and the fps dropped to 30, which is not the case here)
« Last Edit: Tue, Mar 16, 2010 by Liaf »

Richard Kain

  • Active Member
  • ***
  • Posts: 231
  • Karma: +0/-0
    • View Profile
Re: Performance Issues
« Reply #1 on: Tue, Mar 16, 2010 »
Well, for starters, having your framerate drop to 30 FPS isn't something you need to worry about. 30 FPS is considered to be perfectly acceptable by most developers. As far as animation goes, most developers shoot to have a minimum framerate of 24 fps. It's at about that level that most people stop being able to tell the difference between changes in framerate. Someone with good vision and attention to detail will be able to perceive differences in framerate up to around 45-50 fps. At 60 fps and above, its nearly impossible for anyone to pick out the differences in framerate. Bottom line is, 30 fps is just fine, and nothing to get upset over.

As to why your game seems to be lagging every 10 seconds, it could have something to do with a timer function you've implemented in your game's logic. Are you being careful to only use the FlxG.elapsed property for determining movement code? If you have been using Flash's timing routine's, that could account for the discrepancy. It is always a better idea to use Flixel's built in timing feature. That will optimize your performance, since the timing code only has to be run once.

Liaf

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
  • yay!
    • View Profile
Re: Performance Issues
« Reply #2 on: Tue, Mar 16, 2010 »
No, I always used FlxG.elapsed as far as I can see. I used it in about 5 different classes like this in the update function:
Code: [Select]
if(timer > 1.5){
  doSomething();
  timer = 0;
}
timer += FlxG.elapsed;
But i don't think that should be any problem. There are far more complex calculations.

One thing that's bugging me is the following. Like I said it's lagging all 10 seconds a bit (on different computers/browsers), but the framerate never drops when it lags. Could this be more of a problem with Flash Player? I'm currently compiling with Flash Player 9.

EDIT: I'm using Flex SDK 3.5 right now (yes the milestone version, not the stable version  ::) ), currently loading 3.4 to try out if it helps.
« Last Edit: Tue, Mar 16, 2010 by Liaf »

Bjorgen

  • Member
  • **
  • Posts: 59
  • Karma: +0/-0
  • Party hats ftw!
    • View Profile
    • Project Morsel
Re: Performance Issues
« Reply #3 on: Tue, Mar 16, 2010 »
Are you currently using the debug flash player? I know when i wasn't some of the slow downs I was getting were exceptions happening, when i started using the debug flash player they popped up messages instead of just lagging the game.

abielins

  • Member
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Performance Issues
« Reply #4 on: Tue, Mar 16, 2010 »
I found that setting your compile target to the flash player 10.0 can speed up a lot of bitmap stuff quite a bit.

lithander

  • Active Member
  • ***
  • Posts: 222
  • Karma: +0/-0
    • View Profile
    • pixelpracht
Re: Performance Issues
« Reply #5 on: Tue, Mar 16, 2010 »
Lag like you describe it is often due to the garbage collector kicking in. You can get the amount of allocated memory with a call to System.totalMemory. Usually it's rising steadily and drops by a large chunk every couple of frames. See if it drops when you experience the lag frame!

If it is the garbage collector there isn't much you can do except reducing the amount of garbage to clean up. See if you can reuse objects etc...
Simplicity is the ultimate sophistication ~Leonardo Da'Vinci

Liaf

  • Member
  • **
  • Posts: 19
  • Karma: +0/-0
  • yay!
    • View Profile
Re: Performance Issues
« Reply #6 on: Tue, Mar 16, 2010 »
@Bjorgen, I'm always using the debug flash player for debugging, and if i've got a stable build there, I'm trying it out in release flash player to test performance.

@lithander, That's a very nice approach you got there, and I'm definitely gonna remember that for the future. But this time it's not the Garbage Collector. The Total Memory used is always at around ~15700000, and it never goes above 16000000, and I think 300000 bytes shouldn't be that much of a problem^^

@abielins, I tried it out now with Flex SDK 3.4 and compiling with Flash Player 10. That definitely helped a lot. For now I can't see any lag.

Thanks everyone for your posts, this surely helped me a lot.