I've also made a lot of changes recently to take advantage of this. 
Here's a simple test and result to show the differences I've seen.

The query returns 21,596 records.

[49407ms] /CFStringAppend/
[468ms] /javaStringBuffer/

//


With this code:


<cfset stringBuffer = CreateObject( "java", "java.lang.StringBuffer" 
).Init() />

<cfquery name="noms" datasource="#request.dsn#">
    Select ID
    From nomination
</cfquery>

<cfset mystring = "">
<cftimer label="CFStringAppend">
    <cfloop query="noms">
      <cfset mystring = mystring & "this is row: " & noms.CurrentRow & 
"<br />" />
    </cfloop>
</cftimer>


<cftimer label="javaStringBuffer">
    <cfloop query="noms">
      <cfset stringBuffer.Append( "this is row: " & noms.CurrentRow & 
"<br />") />
    </cfloop>
</cftimer>

<cfoutput>
    #stringBuffer.ToString()#
    <hr>
    #mystring#
</cfoutput>

More than 100 times better. That's quite a significant difference, isn't 
it???



*****************
Ken Ferguson
214.636.6126
*****************






Rob Wilkerson wrote:
> I'll second Ben's recommendation.  I changed several of my large
> string concatenations and saw performance increases up to 90% over the
> traditional method.  It really makes a huge difference.
>
> On 6/20/06, Ben Nadel <[EMAIL PROTECTED]> wrote:
>   
>> If you are building a massive string (without appending to a file) I would
>> suggest using the Java StringBuffer. It creates parts of a string and then
>> creates a full string once at the end... HUGE performance advantage over
>> traditional string concatenation:
>>
>> <cfset jstrBuffer = CreateObject( "java", "java.lang.StringBuffer" ).Init()
>> />
>>
>> <cfloop query="qTest">
>>   <cfset jstrBuffer.Append( "this is row: " & qTest.CurrentRow ) />
>> </cfloop>
>>
>> <cfoutput>
>>   #jstrBuffer.ToString()#
>> </cfoutput>
>>
>> .......................
>> Ben Nadel
>> www.bennadel.com
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, June 20, 2006 1:41 PM
>> To: CF-Talk
>> Subject: Export text
>>
>> I need to do a simple download of 100,000 plus records out of SQL. I would
>> like the user to get prompted to save a .txt file They will be using recent
>> versions of IE. I've been playing around with CFHeader and CFContent. It
>> works OK if specify Application/msexcel. Does anyone have any code examples
>> dumping to a text file?
>>
>> Lee
>>
>>
>>
>>
>>     
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244415
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to