You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Marshall Schor <ms...@schor.com> on 2013/07/27 14:23:30 UTC

general point on performance and logging

In other projects, it has been observed via measurement / profiling that the
normal way logging is used:

    call-the-logger(log-level, a message reference, some computed values to
insert into the message)

for cases where the log-level results in no logging being done, results in
observable performance slowdown, due to the time it takes to prepare the logging
data to insert into the message.

If this is trivial, then it's no concern.

If it's significant, involving string concatenations, etc., then it is better to
avoid doing this unless the log level is "met".  One example, where it could be
significant, is in the class ConfigurationManagerImpl, where we log (if the
level is "CONFIG") the values of parameters, and how they came to be set (were
they set in an override of some kind, etc.).  This involves some amount of
computation, which is wasted if the logging isn't needed.

The suggested idiom for logging would be to set a boolean final doLogging
variable before the first bit of work to build logging parameters, and then
bracket code which is there just for logging purposes with if (doLogging) { ... }. 

-Marshall