Jump to content
  • Advertisement
Sign in to follow this  
mreiland

Pygame, help with slowdown

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm putting together a small game and I'm using pygame to do it. I've basically got the underlying 'engine' done, but it seems to absolutely crawl. I'm using a 600x400 window(software). When I don't flip I'm getting reports of an FPS of upwards of 5k. When I put do flip it drops to about around 23 FPS. When I have the flip in there, if I minimize the window it jumps back up to 3k-5k until I restore the window. I'm assuming that either pgyame or SDL has an optimization to not bother actually flipping if the window isn't visible. My monitor refresh rate is 75 hertz. I know that flip will wait for the next vert retrace, but I don't think that should be an issue should it? Unless I'm consistently missing a few retraces and having to wait around. But I don't think that really explains the slowdown seeing as how if I take the flip out the framerate is so high. The other thing that I'm thinking might be the problem is the shuffling of data from memory to the card. I'm in Linux and it's possible that I didn't compile in the correct drivers for my MB(that's something I'll have to check later). Does anyone have any insight into this? Perhaps possible things to look at, that type of thing. If anyone else has ever had that problem, I'd definately appreciate a summary of what you did to resolve the problem. Also, I'm using pygame 1.7.1, and I'm blitting 3 small surfaces to the screen (5-10 letter words, but I'm not rerendering them each frame).

Share this post


Link to post
Share on other sites
Advertisement
You're always going to get slowdown when you flip, regardless of whether you're using pygame, C++, or other. It's usually going to be huge slowdown, too.

That being said, I have had very recent (humbling) experiences with Python and pygame, as far as speed and optimization is concerned. Very small and very non-obvious things can absolutely kill framerate. I spent several hours the other day with Fruny trying to optimize a tile-based map renderer, and there are a lot of things and programming practices that have to be taken into consideration with an interpreted language such as Python in order to get the fastest possible speeds. Intimate familiarity with the language can be extremely beneficial. At one point, I experienced a 5x drop in framerate from the simple act of changing a "from GFX import *" to "import GFX". I'm still not entirely sure what the hell that was all about. [grin]

Fire up the profiler. See where your time is being spent, and figure out what you can do to cut that time down. We used Numeric quite a bit, and things need to be done in exact ways with Numeric in order to maintain efficient performance. Python includes a good profiling system. Use it. It really does help.

Also, as you suggested yourself, make sure everything is kosher in regards to your drivers and library installations. If you are using OpenGL, make sure that the right drivers are installed and that any existing installations of Mesa are not getting in the way.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!