On Wednesday, July 31, 2002, at 10:23 , Brook Davies wrote:
> How does this work? Instead of using evaluate? Is this faster? I have a 
> lot
> of evaluate statements in my code and Ramond Chan's words haunt me ;)

Show us some of your code that uses evaluate() and we'll see if we can 
show you a simpler and/or faster way to write it.

> And, another question. If I have a big long fat list, is it faster to
> convert it to an array and loop over the array than it is to just loop 
> over
> the list or use the listgetat() command?

I would *expect* it to be faster to convert the list once and then loop 
over it. Hmm, I feel a performance test coming on...

Big difference in speed!!! 20x

1000 iterations:
listGetAt took 13589 ms
array took 724 ms

Here's the test:
<cfparam name="URL.loop" type="numeric" default="1"/>
<cfscript>
         loop = URL.loop;
         listOfStuff = "000";
         for ( i = 1; i le 100; i = i + 1 )
                 listOfStuff = listOfStuff & "," & i & i & i;
         s1 = getTickCount();
for ( q = 1; q le loop; q = q + 1 ) {
         len = listLen(listOfStuff);
         for ( i = 1; i le len; i = i + 1 )
                 x = listGetAt(listOfStuff,i);
}
         e1 = getTickCount();
         s2 = getTickCount();
for ( q = 1; q le loop; q = q + 1 ) {
         arrayOfStuff = listToArray(listOfStuff);
         len = arrayLen(arrayOfStuff);
         for ( i = 1; i le len; i = i + 1 )
                 x = arrayOfStuff[i];
}
         e2 = getTickCount();
</cfscript>
<cfoutput>
#loop# iterations:<br/>
listGetAt took #e1 - s1# ms<br/>
array took #e2 - s2# ms<br/>
</cfoutput>

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.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

Reply via email to