> -----Original Message-----
> From: Sylvain Wallez [mailto:[EMAIL PROTECTED]] 
> Sent: woensdag 5 december 2001 18:13
> To: [EMAIL PROTECTED]
> Subject: Re: Cocoon 2.0 Scalability Disappointment
> 
> Peter Royal a écrit :
> > 
> > On Wednesday 05 December 2001 10:36 am, Tom Klaasen 
> (TeleRelay) wrote:
> > > Use StringBuffers. Check for log.isDebugEnabled(). 
> Especially in loops.
> > > In May, this speeded up our application from 1s to 0.1s 
> for certain
> > > pages (a speedup of euh... has anyone studied advanced math? ;) )
> > 
> > And be sure to set reloadable=false for the context in tomcat!
> > 
> > When you mention use StringBuffers, is it better to do
> > 
> > StringBuffer sb = new StringBuffer();
> > 
> > return sb.append("this").append("is").append("a string");
> > 
> > rather than
> > 
> > return "this" + "is" + "a string";
> > 
> > ?
> > 
> > I was under the impression that the compiler would optimize 
> the second case.
> > I do know to use a StringBuffer when in a loop that you're 
> appending to a
> > string in tho :)
> > -pete
> > 
> > --
> > peter royal -> [EMAIL PROTECTED]
> 
> I studied in detail the generated byte code for both types and came to
> the conclusion that using StringBuffer is only useful when 
> the string is
> built in separate statements (such as in a loop). For more 
> details, see
> :
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=100413627531535&w=2

That's the mail I remembered and resummarized very concisely ;-) and I
think it also lingered somewhere in Pete's brain.

> BTW, using isDebugEnabled() is only useful if the message is a
> concatenation of strings. If it's a static string, it can 
> even be slower
> if debug is enabled because of the double check !

I agree totally.
Of course, isDebugEnabled() is also necessary when you're doing
extensive calculations for your debugging message, but I think that
speaks for itself.

tomK

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to