Premature Optimization

Started by
7 comments, last by Galapaegos 18 years, 7 months ago
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.
Advertisement
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.
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

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 :)
No one knows?
For profiling your visual studio apps, you'll probably want to use this Devpartner Profiler, Community edition, unless there's a better free profiler out there.

As for profiling in Debug mode, people say you're meant to profile in Release mode, but I can't get Devpartner profiler to work in release mode :(
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.
Are you using STL?

That has quite a reputation for poor performance in debug mode and very good performance in release.
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
-brad

This topic is closed to new replies.

Advertisement