Logger performance

K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was looking at the Logger classes the other day and I read some claims
about the performance of the Logger that I found a bit hard to believe.

Ideally what one would like is a system like the assertion system where
logging code is only executed when it is above the level being filtered
by the logging system so code like this:

thisLogger.finest("My info: " + SomeObject.performComplexCalculation());

would not execute except when the user was requesting logging at the
finest level.

I don't believe the Logger is handled this way. It would require
compiler support that I don't believe exists, wouldn't it?

Am I correct in understanding that logging should not be used in inner
loops, even for debugging (if it will be in the code in production)?

Thanks.

- --
Kenneth P. Turvey <[email protected]>
http://kt.squeakydolphin.com (not much there yet)
Jabber IM: (e-mail address removed)
Phone: (314) 255-2199


(If you've seen this message once before, I apologize. I canceled the
wrong one.)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDLjEV3naBnF2rJNURAtycAJ9M9m4/F9HlhDYko2S4NhQnfbZqeACgrpRN
bB5dtLoiBRDm2N1DJaOg4JE=
=nAsn
-----END PGP SIGNATURE-----
 
R

Roedy Green

thisLogger.finest("My info: " + SomeObject.performComplexCalculation());
if you surrounded the call in

if ( DEBUG )
{
}

It should be safe since if DEBUG is a compile time constant, no code
inside the {} will be generated if DEBUG is false.
 
K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

if you surrounded the call in

if ( DEBUG )
{
}

That isn't ideal because DEBUG is a compile time constant but you may
want to change its value at run time after it has been deployed. That's
part of the point of the Logger.

This isn't a problem for me, but I had heard that they did incredible,
in the strict sense, thing. I would love to have a system like assert
for this. It would be even better if it didn't clutter the code. I
don't know quite how it could be done cleanly.


- --
Kenneth P. Turvey <[email protected]>
http://kt.squeakydolphin.com (not much there yet)
Jabber IM: (e-mail address removed)
Phone: (314) 255-2199
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDLmIh3naBnF2rJNURAoMoAJ4svE/DBr/yPgarqLRRwBuIE2X9KgCgjolv
oBUFoUKRhzIPNFtOWZ4PBHE=
=7bEL
-----END PGP SIGNATURE-----
 
R

Roedy Green

This isn't a problem for me, but I had heard that they did incredible,
in the strict sense, thing. I would love to have a system like assert
for this. It would be even better if it didn't clutter the code. I
don't know quite how it could be done cleanly.

The code would have to be marked in the class file so that the class
loader ignored it if some global variable were set. The catch is, for
logging you need a lot more than just a single boolean (are asserts in
effect).

I supposed you could implement it by reading class files, and
stripping out code that was not needed FOR THIS RUN.

Marking the variable that enables it final would enable the jit to
dump the code that was not needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Logger performance 5
Array declaration compiler bug? 3
Executor 8
Binomial Simulation 16
Java 1.6 13
Parameters (command line, preferences, user input) 1
Beowulf clusters 9
Simple GUI problem 1

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top