Jump to content
  • Advertisement
Sign in to follow this  
ic0de

Optimization philosophy and what to do when performance doesn't cut it?

This topic is 1514 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

Advertisement

Personally, I tend to prototype a feature first until it's functional and then spend a bit of time to clean up the code and optimize it straight after (hopefully without breaking it -.-). Then once a week or so I spend a day reviewing all the things I did that week and refactoring. There's no set schedule for this, I just do it when the mess starts bugging me (which is at pretty regular intervals). I don't go overboard with optimization though - just enough to keep things from getting too ridiculous.

Share this post


Link to post
Share on other sites

Typically at the start of a project you establish a performance target you need to hit on some particular configuration of hardware (often the minimum and regular specification hardware), and then at regular intervals throughout development perform benchmark tests on this hardware using consistent procedures, and schedule optimizations based on the results. Ideally this process is automated, so that you can perform a ton of benchmarking test across all the various game levels and content without requiring dedicated developer time. Automated testing also helps ensure that the testing procedures remain as consistent as possible and you eliminate any human error.

 

If you blow your performance target, or there's some change made that drastically alters performance, you know it's time to take a look at what happened. The more often the benchmarking is performed, the less code you need to review and profile.

 

Edit: To expand on what I alluded to above, overall performance is about more than just code itself. Sometimes perfectly reasonable code will interact with certain content in ways you didn't expect.

Edited by Zipster

Share this post


Link to post
Share on other sites

I frequently find myself having to choose between a more readable line and a faster line. I then leave myself a big comment like this:

// Performance: use Hard2ReadFunc1() + Hard2ReadFunc2()
x = EasyToReadFunction()

That way I can save the brain power, but I will only optimize it if profiling leads me to that spot.

Share this post


Link to post
Share on other sites

So we have 2 ways of looking at this where both have truth.

 

It's worth noting that some design-time choices will have a major impact on speed. Choosing to implement some system around data access patterns instead of some sort of object hierarchy is a pretty big decision, and with just a little experience can easily be determined before-hand, even though it could be considered a type of optimization. I would rather do this before rather than after.

 

However, optimizing my collision detection system for 2 days when I only have 10 objects on the screen at a given time is almost guaranteed a waste of time, but profiling later on will help us determine this for sure.

Share this post


Link to post
Share on other sites

Spiro, for your #2, and that sin/cos, do you think the compiler wouldn't optimize the initial version?

 

(Not disagreeing with your point, there are lots of instances of small optimizations that, as long as they don't make the code less clear, and don't take a lot of time, should just be done.)

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!