I have a couple of sections of code that are very processor intensive. I have debug statements in there for internal deployments and testing but when I deploy to my customer sites I would like to do a build that doesn’t have these. I currently use:
ifIsDebugEnabled()
to wrap the log messages but this is also taking up processor time and when I commented all the logging out the performance improved. Is there a standard way to go about this or are there other things I can do instead?
Thanks,
Richard
To optimize out method calls, you can put the
ConditionalAttributeon methods. Like this:Calls to this method will be removed if the code is compiled in another configuration than DEBUG.
This is a cleaner looking way than using directives like
#ifdef DEBUG .. #endif, if you can afford to put your Debug logic in Methods.