cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <>
Subject Re: Performance of loggin
Date Wed, 07 Mar 2001 14:20:26 GMT
Giacomo Pati wrote:
> Hi all
> I've recently made a copy of C2 without any log.debug() statements in it for a
> test how much performance we loose using it that extensively. I've written a
> script that comments out every possible .debug() use in the sources (I confess I
> had to edit the sitemap.xsl manually but this wasn't much effort) I've used the
> ApacheBench tool for the mesurement.
> Well, probably someone else should made this test independantly (I may
> have done something wrong) because I haven't found *ANY* significant differences
> ??!! I've tested it several time with and without XSLT on the welcome page and
> everytime I get the same differences (less that 10ms per request).
> Does anybody may have a reason why?

Peter Donald is the guy behind the LogKit.  I think he did a wonderful job with it.
He carefully balanced performance with functionality--always opting for the least
costly method of doing things.  Also, when you specify a minimum log level, it
opts out early (why bother processing it further) so as to have the minimum impact
on performance.

One thing that slows down servlets alot is using context.log(...) extensively as
it is a costly method.  Cocoon only forwards Priority.ERROR messages to that logger
so the traffic is limited to real errors.

Also, the real performance detractor in these cases are the compound strings that
would have to be assembled (you know: "string1" + "string2").  In most places this
has been either reduced to one compound or StringBuffers.

For example which is more readable:

getLogger().debug("Error in Component: " + componentName, e);

- or -

getLogger().debug(new StringBuffer("Error in Component: ").append(componentName).toString(),

Obviously the previous one.  In code, they have the exact same affect.  You don't
start realizing the performance advantages of the StringBuffer until you have 3 or more
strings to add together.

"Error in Component '" + componentName + "'"

is equivalent to:

new StringBuffer(new StringBuffer("Error in Component '").append(componentName).toString()).append("'").toString();

Besides, Cocoon is blazingly fast anyway.  To perform the same look and feel in
ColdFusion (I know I keep using that tired example, but I have personal experience
with it) with the same modularity, the page would take twice as long.  That is
incredible when you think about it.

View raw message