Jochem van Dieten wrote:
>
[..]
Code to wrap lines using a loop and Insert() was significantly slower on
CF MX as CF 5. Complete thread can be found in the archive:
http://www.houseoffusion.com/cf_lists/index.cfm?method=messages&threadid=14563&forumid=4
[..]
> The numbers:
> CF 5 MX JRE 1.3 MX JRE 1.4
> 9 KB 40 50 60
> 24 KB 240 3300 7000
> 84 KB 6700 130000 174000
I rewrote the code to use an array instead of a raw string. Basically
chop up the string in 72 byte substrings, put those in an array and use
ArrayToList() to put it all together again using Chr(10) as delimiter
(code below).
The new numbers with MX JRE 1.3 (no patches):
Old code New code
9 KB 50 0
24 KB 3300 10
84 KB 130000 50
I didn't feel the need to test other JRE's anymore :)
On a similar note, I have seen a performance increase of a factor 90 by
replacing ListDeleteAt() by a UDF that converts the list to an array,
deletes an item and converts the array back to a list (1100 item list).
I think every best practice for CF MX should include a note to avoid
string/list manipulation for anything but the smallest string/list.
Jochem
--
New code (mind the wrap):
<cfscript>
request.File = "";
CRLF = chr(10);
CurrentPosition = 1;
tempArray = ArrayNew(1);
</cfscript>
<cffile action="READ" file="#request.file#" variable="temp"/>
<cfscript>
temp = ToBase64(temp);
if (Len(temp) MOD 4 IS "1")
temp = RemoveChars(temp, Len(temp) - 1, 1);
request.StartTime = GetTickCount();
while (CurrentPosition LTE Len(temp)) {
ArrayAppend(tempArray, Mid(temp, currentposition, Min(72,Len(temp) -
currentposition + 1)));
CurrentPosition = CurrentPosition + 72;
}
temp = ArrayToList(tempArray,CRLF);
WriteOutput(GetTickCount() - request.StartTime & " ms");
</cfscript>
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists