if(isLoggingDebug()) {
logDebug("some string");
)
and
myclasslogDebug("some string");
with a method:
myclasslogDebug(String foo) {
if(isLoggingDebug() ) {
logDebug(foo);
}
}
is that in the first case the VM does not have to create the string
"some string", in the second case it does.
When I code I try not to instantiate something that is not needed.
This is why the ATG framework is the way that it is. if you have to
pass the string in, your performance will degrade as you put more and
more debug statements in. A simple boolean check against the method
call "isLoggingDebug()" is pretty painless and has a trivial impact on
performance. The first time I touched ATG on v4.x (yes a long time
ago) I was not aware of the boolean check. When we realized that
design of the boolean check and added it into all of our logging
statements the performance of the site close to doubled. Granted this
was a while ago and major improvements have been made in string
handling in the JVM but still....
It is up to you how you go about this. There is a valid argument for
readability of code. I personally do not thing it outweighs the
argument for degraded performance.
Gordon Cooke
Spark:red - Managed ATG Hosting
Gordon Cooke
Spark::red - Managed ATG Hosting