You can easily eliminate the evaluate() as a factor by replacing
<cfset field = evaluate("resultSet.#ThisColumn#")>
with
<cfset field=resultSet[ThisColumn][resultSet.currentRow]>
but it doesn't look like you're executing that line enough times to account for
the performance problem.
Reed
>I have some code that dynamically generates CSV, TAB, and EXCEL (HTML
>tables) from a query, and it is running pretty slowly. A lot slower
>than I'd like it to. Essentially, I set a bunch of variables like
>START_PAGE, END_PAGE, START_ROW, END_ROW, START_FIELD, and END_FIELD
>that allow me to loop through the query and loop through the list of
>fields and output the data in the appropriate format.
>
>I added some debugging code and generating 124 rows took 19 seconds.
>Generating 1416 rows took 309 seconds. Which means if someone wants to
>generate a drop with 5,000 rows, it's gonna take a long freakin' time!
>
>It seems like it shouldn't be that slow. It's only writing every 100
>rows to disk (the 124 record file was 445KB). And a couple of cflog
>statements indicate that the file write takes less than a second.
>
>Here's the query loop that outputs the rows of data.
>
><cfloop query="resultSet">
> <cfset fileOutput = fileOutput & START_ROW>
> <cfloop list="#fields#" index="ThisColumn">
> <cfset field = evaluate("resultSet.#ThisColumn#")>
> <cfif field eq "" and format eq "EXCEL"><cfset
> field=" "></cfif>
> <cfset fileOutput = fileOutput & START_FIELD>
> <cfif format eq "CSV">
> <cfset fileOutput = fileOutput & csvFormat(field)>
> <cfelse>
> <cfset fileOutput = fileOutput & FIELD>
> </cfif>
> </cfloop>
> <cfset fileOutput = fileOutput & END_ROW>
> <cfif currentRow MOD 100 is 0>
> <cflog text="writing file #now()#">
> <cffile action="APPEND"
>file="#application.udf.ROOT_DIR#\tools\entityLookup3\drops\#filename#"
>output="#fileOutput#" addnewline="No">
> <cflog text="done writing file #now()#">
> <cfset fileOutput = "">
> </cfif>
></cfloop>
>
>I suspect that it's the Evaluate() that's running slowly.
>
>Any ideas on how to speed this code up?
>
>Thanks!
>
>Rick
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250298
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4