Sign in to follow this  
Kest

Premature Optimization

Recommended Posts

I'm trying to do some premature optimization, and in debug mode no less. My animation engine is really bogging down the system when it loads animations on the fly. There is quite a hefty number of routines and systems that run to get an animation loaded in. It's mostly due to the fact that it is debug mode, as release mode is quite a lot faster. Still, it is very annoying. It's difficult to debug my game with so much loading. So I would like to increase the speed of this operation. Like I said, though, a lot of routines go into the load, so I need something like a profiler. I'm a total profiler newbie, so I'd like to ask some questions. Is it possible to use a profiler in debug mode? I can't seem to find any profiling options for C++ in MSVC.net (version 7). Details in "what's new" explain how several profiling commands have been removed. Were they replaced by something, or did they just ditch it? I also found details about starting a profiler up, but it seemed very .NET based (the COR_ENABLE_PROFILING and COR_PROFILER stuff). Will that work with my C++ code? Any help getting that up and running would be spectacular. Thanks for any help.

Share this post


Link to post
Share on other sites
If you're primarily concerned with debugging at a reasonable speed, check out the #pragma optimize directive. It'll let you single out a specific piece of code to be optimized even in Debug mode.

Share this post


Link to post
Share on other sites
premature optimiation is when you optimise before there is a need, and generally is a term applied to optimisations that are pratically useless.

you have a speed problem - so you add actual optimisations...

you're going around it the right way - profiling the code to see where the speed problem actually is.

i use dev-cpp, so can't tell you anything about profiling with your enviroment

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
If you're primarily concerned with debugging at a reasonable speed, check out the #pragma optimize directive. It'll let you single out a specific piece of code to be optimized even in Debug mode.

Well, it's more than just optimizing the compiled code. I'm thinking that there must be something working in this code that is really crunching the CPU. It's possible such a task could be completely avoided or done an entirely different way. But I need help finding those problems.

Thanks for the info though :)

Share this post


Link to post
Share on other sites
I suggest profiling your code at points where the slowdown occurs in debug mode (i.e. run your code with a profiler and try to recreate the problem in your application). This should give you an idea of where the slowdown is occuring and will allow you to turn optimizations on for the relevant functions in debug mode or to at least identify the sections causing trouble.

Profiling in debug mode when you want a speed increase in release mode is dumb, but there's nothing wrong in profiling in debug mode if you are looking for a speed increase in debug mode.

It's an unfortunate problem that it's debuf mode is sometimes needed to track down problems, but can also be unbareably slow.

Share this post


Link to post
Share on other sites
Are you using STL?

That has quite a reputation for poor performance in debug mode and very good performance in release.

Share this post


Link to post
Share on other sites
Kest,

If you need help singling out what your bottle necks are, you should download the amd performance analyser. All you do is hook up the executable and the source code, and away you go! It makes a nice table of all the functions that were called per frame, and the number of times a function was called in a frame.

If your wanting to profile yourself, I'd suggest looking at an article in Game Programming gems (forget which number, hopefully someone reading this knows). It was pretty good describing a high level view of writing your own.

-brad

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this