Quoting QM <[EMAIL PROTECTED]>:
> On Tue, May 25, 2004 at 03:39:31PM +0200, Rostislav Svoboda wrote:
> : I'd like to ask you if there's a significant difference in performance
> : between:
> :
> : String ret = "";
> : for (count = 0; rs.next(); count++)
> : ret += rs.getString("column_name"); // result of db query
> : out.print(ret);
> :
> : and:
> :
> : for (count = 0; rs.next(); count++)
> : out.print(rs.getString("column_name"); // result of db query
> :
> : I know I have the extra string which is (theoretically) a slow-down but I
> : don't
> : know anything about the way how tomcat handles with large strings (in my
> : case about 1MB), if is there any limited buffering etc.
>
> 1/ what happens when you load-test the two variations?
>
> 2/ it's not about Tomcat handling strings; it's how the underlying JVM
> handles strings.
>
> 3/ what happens when you load-test the two variations?
>
> 4/ depends on the JDK; newer compilers /may/ see a repeat string concat
> ("+" op) and replace w/ StringBuffer under the covers...
>
This is a common psuedo-misconception. Compilers can't do anything with strings
that have a paramter of which the value can only be realized at runtime.
public static String OPTIMIZED = "optimized";
"This can be " + OPTIMIZED + " at compile time to a single string with no
concatenation at runtime"
private String optimized;
"This cannot be " + optimized + " at compile time. It *has* to be evaluated at
runtime because the value isn't available at compile time"
Jake
> 5/ what happens when you load-test the two variations?
>
> But, as always, see #1 for the end-all, be-all answer.
>
> -QM
>
> --
>
> software -- http://www.brandxdev.net
> tech news -- http://www.RoarNetworX.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]