#1 Members - Reputation: 255
Posted 07 November 2012 - 05:39 PM
I was looking at the framerate I get between an executable (C++) compiled on Debug mode (with VisualStudio), and on Release mode. I expect Debug mode to run slower, but I'm getting ~8fps running in Debug mode versus ~30fps running in Release mode.
I've analyzed what functions the performance comes from, but, but... I really don't know how to tackle the issue, since it's Debug mode I'm not too worried about, but sometimes it's not easy to debug other stuff running so slow...
Obviously the code is the same on both, so... how could I improve the performance running in Debug mode?
Any ideas?..
Thanks!
#2 Moderators - Reputation: 6640
Posted 07 November 2012 - 06:01 PM
#3 Members - Reputation: 1410
Posted 07 November 2012 - 06:38 PM
The next thing to do to speed up the debug code is to change some compiler settings. See http://randomascii.wordpress.com/2011/07/22/visual-c-debug-buildsfast-checks-cause-5x-slowdowns/
You can also adjust your compiler settings on a per project, or per file basis which means you can leave optimizations off for easy debugging in the part of the code you're working on while having optimizations enabled elsewhere (e.g. debug game play code, with optimized rendering).
After that you need to profile the code, so you know where to optimize. You can do this on the debug code, but I'd suggest starting with the optimized code. You can get a decent free profiler at http://www.codersnotes.com/sleepy/
#4 Moderators - Reputation: 13521
Posted 07 November 2012 - 07:34 PM
The 3 builds that I use are:You may want to consider using three configurations:debug mode, release mode and release with no optimizations.
Debug - all assertions + no optimisation + debug symbols
Development - most assertions + mostly optimised + debug symbols
Shipping - no assertions + fully optimised + debug symbols
#5 Members - Reputation: 682
Posted 07 November 2012 - 08:09 PM
How do you have "most assertions"? You have different kinds of "assert" statements?Development - most assertions + mostly optimised + debug symbols
http://www.cpgf.org/
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.
#6 Senior Moderators - Reputation: 3113
Posted 07 November 2012 - 08:23 PM
How do you have "most assertions"? You have different kinds of "assert" statements?
Development - most assertions + mostly optimised + debug symbols
Yes.
assert is just a macro, and you can define your own versions which can be optionally excluded based on preprocessor conditions. It can be useful to have a larger set of assertions for debug build, and a smaller set of them for a test build.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX
#7 Moderators - Reputation: 13521
Posted 07 November 2012 - 08:40 PM
#define DEBUG_LEVEL 2 //this shouldn't be a #define; it should be set by the project config
#define DECLARE_DEBUG_MODULE( name, level ) const static bool dbg_##name = level <= DEBUG_LEVEL;
#define ASSERT( module, condition, message ) \
do { if( dbg_##module && !(condition) ) { AssertionFailure(__FILE__,__LINE__,message,#condition,#module); } } while(0)
void AssertionFailure( const char* file, int line, const char* message, const char* condition, const char* module )
{
//print text, show dialog, __debugbreak(), etc...
}
DECLARE_DEBUG_MODULE( FooBar, 2 ); // 2 == only debug, 1 == debug and development, 0 == all builds
void Test()
{
ASSERT( FooBar, 1==2, "test" );
}
#8 Crossbones+ - Reputation: 5155
Posted 07 November 2012 - 08:58 PM
MSDN
L. Spiro
Edited by L. Spiro, 07 November 2012 - 09:22 PM.
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
#10 Members - Reputation: 595
Posted 12 November 2012 - 09:02 AM
I can strongly recommend this. Except i use it in reverse - disable optimizations in sections i currently have problems with.Note that you can enable certain optimizations for certain sections of code if you are sure those sections work and are causing you performance problems.
MSDN







