I prepare inventory files to upload to Half.com and Amazon marketplace.
Some 150k records or so.
I used to run the script so that I appended each row to a variable, then
when done, wrote this variable to a file - thinking that the variable
would take less time that writing to a file 150k times.
WRONG!
I rewrote the script to write to the file each iteration instead of memory
and the time it took to run when from 22 hours to 1 hour.
I wrote some sample code to compare the two loops and found that the time
it took to complete the variable->file loop increased almost exponentially
as the number of iterations went up while the file loop increased in a
nice linear fashion.
> I have this loop that runs ~22,000 iterations. It brings the server to its
> knees. The RAM usage skyrockets above 800 Megs cutting into major virtual
> memory. But when I just write the output instead of storing it to a
> variable, it runs fine. I'm trying to retrieve a list of email addresses
> and then write them to a file.
>
> <cfscript>
> emails = "";
> for( i = 1; i lte list.recordcount; i=i+1 )
> {
> emails = emails & list.email[i] & chr(13) & chr(10);
> }
> </cfscript>
>
> I can't imagine that the list in memory would take that much room. Does
> anyone have a suggestion?
>
> --
> Chris Edwards
> Web Application Developer
> Outer Banks Internet, Inc.
> 252-441-6698
> [EMAIL PROTECTED]
> http://www.OuterBanksInternet.com
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4