On 22 November 2012 17:51, Radim Kolar wrote:

instead of this:

if (logger.isDebugEnabled())
logger.debug("INDEX LOAD TIME for " + descriptor + ": " +
(System.currentTimeMillis() - start) + " ms.");

do this:
logger.debug("INDEX LOAD TIME for {} : {} ms.", descriptor,
(System.currentTimeMillis() - start));
Yes, but until/unless the JVM elides the function call because that logger
is not enabled fro debug, you will incur the penalty of new
Object[]{string,new Long(System.currentTimeMillis() - start).

On top of that, when debug is enabled you incur the cost of formatting the
string, including the {} search & replace.

On a long running production system, you are correct that it should
*eventually* be equivalent, and I am not saying one way or the other
whether this should/shouldn't be changed... more just pointing out that
there are consequences to what might appear to be a trivial change... I'll
let the c* devs chime in as to what their strong opinion is in this regard
as they should have more experience handling high loads and I would love to
know which pattern I should be using in my code (FWIW I tend to favour your
approach to the if (debugEnabled) guard... but I always wonder ;-) )


easier to read.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 7 | next ›
Discussion Overview
groupdev @
postedNov 22, '12 at 5:52p
activeNov 23, '12 at 7:09p



site design / logo © 2021 Grokbase