Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #4565
| From | Nigel Wade <nmw-news@ion.le.ac.uk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: analysis of java application logs |
| Date | 2011-05-25 09:53 +0100 |
| Message-ID | <943uboF6qmU1@mid.individual.net> (permalink) |
| References | (3 earlier) <irg8b1$ibj$1@localhost.localdomain> <irgfs0$k9d$1@localhost.localdomain> <irgm61$944$1@news.albasani.net> <240520111100099912%jimsgibson@gmail.com> <irgtpb$qoi$1@news.albasani.net> |
On 24/05/11 19:35, Lew wrote:
> On 05/24/2011 02:00 PM, Jim Gibson wrote:
>> In article<irgm61$944$1@news.albasani.net>, Lew<noone@lewscanon.com>
>> wrote:
>>
>>> Martin Gregorie wrote:
>>>> Lew wrote:
>>>>> Martin Gregorie wrote:
>>>>>> Fair point. However, my usual debugging statement takes the form:
>>>>>>
>>>>>> if (debug> 0)
>>>>>> debugger.trace(result + " = method(" + arg + ")");
>>>>>>
>>>>>> Ugly, I know, but quite efficient, since when debugging is off
>>>>>> even the
>>>>>> cost of the method call cost is. I use an integer to control
>>>>>> debugging
>>>>>> rather than a boolean so I can control its volume: "java Application
>>>>>> -dd" would be expected to provide more detailed debugging output than
>>>>>> "java Application -d"
>>>
>>>>> What's wrong with
>>>>>
>>>>> if ( logger.isDebugEnabled() ) ...
>>>>>
>>>>> or
>>>>>
>>>>> if ( logger.getLevel().isGreaterOrEqual( Logger.DEBUG )) ...
>>>>> ?
>>>
>>>> Not a lot, though that does involve method call overheads that you may
>>>> not want in a tight loop.
>>>
>>> Seems like it's a simple equality test that would be HotSpotted away.
>>
>> My understanding of the log4j and java.util.Logger classes is that each
>> logger exists within a hierarchy of classes, and that to determine
>> whether or not a specific logger call will produce output, the library
>> must test each level, starting at the specific class and traversing
>> upwards in the hierarchy.
>>
>> So using a static variable as below to enable and disable logging
>> output can save some execution time:
>>
>> static final boolean debug = false;
>>
>> if( debug ) {
>> logger.debug(...);
>> }
>>
>> Whether or not that is significant, depends upon the situation, of
>> course.
>
> All this theory indicates what to measure in any real situation, but to
> echo your "of course", you won't know what to conclude prior to that
> measurement.
In my specific example above I resolved the "problem" by using my own
class which did pretty much exactly as Lew suggested in his follow-up
post. When I subsequently profiled the code the execution time, and CPU
time, required by the remaining method invocations was negligible.
>
> Now why you'd *ever* want to put a log statement inside a tight,
> performance-critical loop in the first place is a whole 'nother question.
>
In my case the loop was reading messages from a network and generating
responses. The logging code was to log the message received, and the
response generated, during development. At this stage it wasn't deemed
to be performance critical, but was essential to verify correct receipt
of the network message.
It wasn't until much later that I was told that the response had to be
returned in less than 40uS (a fact that wasn't in the original
requirements). So I profiled the code to find out where optimisation
ought to be targeted. I still wanted to keep the logging in the code for
debugging purposes, since it was still under active development, but be
able to disable it (and its overhead) for testing.
--
Nigel Wade
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
analysis of java application logs Ulrich Scholz <d7@thispla.net> - 2011-05-23 00:50 -0700
Re: analysis of java application logs Robert Klemme <shortcutter@googlemail.com> - 2011-05-23 02:20 -0700
Re: analysis of java application logs jlp <jlp@jlp.com> - 2011-05-23 11:45 +0200
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-23 09:11 -0400
Re: analysis of java application logs Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-23 19:16 +0200
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-23 15:02 -0400
Re: analysis of java application logs Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-23 22:03 +0200
Re: analysis of java application logs Michael Wojcik <mwojcik@newsguy.com> - 2011-05-26 14:43 -0400
Re: analysis of java application logs Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-05-23 18:32 -0300
Re: analysis of java application logs Ulrich Scholz <d7@thispla.net> - 2011-05-25 06:00 -0700
Re: analysis of java application logs Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-05-25 19:04 -0300
Re: analysis of java application logs Martin Gregorie <martin@address-in-sig.invalid> - 2011-05-23 22:25 +0000
Re: analysis of java application logs Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-05-24 12:26 +0100
Re: analysis of java application logs Martin Gregorie <martin@address-in-sig.invalid> - 2011-05-24 12:29 +0000
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-24 08:49 -0400
Re: analysis of java application logs Martin Gregorie <martin@address-in-sig.invalid> - 2011-05-24 14:37 +0000
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-24 12:26 -0400
Re: analysis of java application logs Jim Gibson <jimsgibson@gmail.com> - 2011-05-24 11:00 -0700
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-24 14:35 -0400
Re: analysis of java application logs Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-05-25 09:53 +0100
Re: analysis of java application logs Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-24 19:12 +0200
Re: analysis of java application logs Patricia Shanahan <pats@acm.org> - 2011-05-23 06:17 -0700
Re: analysis of java application logs Robert Klemme <shortcutter@googlemail.com> - 2011-05-23 20:33 +0200
Re: analysis of java application logs Martin Gregorie <martin@address-in-sig.invalid> - 2011-05-23 19:07 +0000
Re: analysis of java application logs CncShipper <anon@nowhere.com> - 2011-05-23 14:56 +0000
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-23 11:43 -0400
Re: analysis of java application logs jlp <jlp@jlp.com> - 2011-05-23 18:00 +0200
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-23 12:20 -0400
Re: analysis of java application logs Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-23 19:06 +0200
Re: analysis of java application logs Robert Klemme <shortcutter@googlemail.com> - 2011-05-23 20:27 +0200
Re: analysis of java application logs Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-05-23 21:02 +0200
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-23 15:06 -0400
Re: analysis of java application logs Robert Klemme <shortcutter@googlemail.com> - 2011-05-23 22:10 +0200
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-23 17:04 -0400
Re: analysis of java application logs Tom Anderson <twic@urchin.earth.li> - 2011-05-24 15:04 +0100
Re: analysis of java application logs Martin Gregorie <martin@address-in-sig.invalid> - 2011-05-24 14:50 +0000
Re: analysis of java application logs Michael Wojcik <mwojcik@newsguy.com> - 2011-05-26 14:58 -0400
Re: analysis of java application logs Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-30 16:23 +1200
Re: analysis of java application logs Lew <noone@lewscanon.com> - 2011-05-30 01:08 -0400
csiph-web