Brad Bourn wrote:
I am making a lib that process statistics/odds
It does a TON of conditional processing and makes extensive use of STL.
I used to be able to process about 1200 sets of numbers / second.
I added a bunch code and comments all over the place for debugging information out to the console. When running in debug it is EXTREMELY slow, which is acceptable. When running without the debug statements it is now at about 300 sets/second. (I added a bunch of complication and recursive functions which slowed it down). I had setup a bunch of if statements to see if I'm in debug mode or not so it doesn't write out to the console if not. By commenting out all the if statements in one recusive function gives me about 100 sets/second more.
my question is this
is there a way to define "//" to be replaced?
e.g.
// how it is now if(debug) qDebug("this");
// what I'd like
#define DEBUG_PRINT // //#define DEBUG_PRINT qDebug
DEBUG_PRINT("this");
If I use #ifdef 's then the code is hard to read e.g.
for(x) { for(y) { for(z) { #ifdef DEBUG qDebug("here I am"); #endif somestatment(blah); andanotherone(blah); if(somehting) { #ifdef DEBUG qDebug("here I am again"); #endif conditional(blah); } } } }
any help would be appreciated
B-)
What about just doing something like this: #DEFINE DEBUG_MODE 1 if(DEBUG_MODE){ //debug code here} and just change the define to 0 for release. Most compilers should see the statement can never be executed and remove it. -- -Chris Kwasneski Software Engineer Yuma Proving Grounds