> <cfset bla = form["item_#i#"]> is fastest
> <cfset bla = evaluate("form.item_#i#")> comes in second place
> <cfset bla = evaluate("form.item_" & i)> comes in last
> 
> This is over a 100000 counter loop

Just to expand on this:

<cfset variables.test1 = "some value">
<cfset preamble = "test">
<cfset index = 1>
<cfset loopMax = 100000>

Bracket notation with in-line variable evaluation
<cf_timeit><!--- this just returns the milliseconds between start and
finish tags --->
<cfloop index="i" from="1" to="#loopMax#">
        <cfset temp = variables["#preamble##index#"]>
</cfloop>
</cf_timeit>
<hr />
Bracket notation with concatentated variable evaluation
<cf_timeit>
<cfloop index="i" from="1" to="#loopMax#">
        <cfset temp = variables[preamble & index]>
</cfloop>
</cf_timeit>
<hr />
Evaluate with in-line variable evaluation
<cf_timeit>
<cfloop index="i" from="1" to="#loopMax#">
        <cfset temp = evaluate("variables.#preamble##index#")>
</cfloop>
</cf_timeit>
<hr />
Evaluate with concatentated variable evaluation
<cf_timeit>
<cfloop index="i" from="1" to="#loopMax#">
        <cfset temp = evaluate("variables." & preamble & index)>
</cfloop>
</cf_timeit>
<hr />



Yields results like:
Bracket notation with in-line variable evaluation Runtime: 547ms
Bracket notation with concatentated variable evaluation Runtime: 703ms
Evaluate with in-line variable evaluation Runtime: 735ms
Evaluate with concatentated variable evaluation Runtime: 687ms

And the results were similar across multiple tests, sometimes erring in
favour of the evaluates, but mostly not.

However the results are sufficiently close as to not really being worth
worring about, I reckon.

(Oh... this is CFMX61, P4-2600MHz, WinXP Pro)

My take on this sort of thing is "why use a function when you don't need
to?".  Hence always run with the square bracket notation.

Adam

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to