Michael, check out what happens when you remove the second line from both
(cfscript for loop and cfloop) loops. If you only have one statement in the
loop, the cfloop speeds up enough to beat cfscript.

Also, this:

 for(i=1; i LTE 10000; i = i + 1){

is a lot faster than

 for(i=1; i LTE Var; i = i + 1){


=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Allaire

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda

> -----Original Message-----
> From: Michael Dinowitz [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 11, 2001 6:27 PM
> To: CF-Talk
> Subject: (code) Looping is faster in 4.5.2
>
>
> In the past both myself and many others have written and said how
> CFLOOP is
> faster and more efficient than the loops within CFSCRIPT. I was just doing
> some tests and found that this is no longer true. It seems that as of CF
> 4.5.2, CFSCRIPT loops are the more efficient loops with the for
> loop looking
> slightly better than the while loop. These are my findings, but I'd like
> others to play with this as well and give me their results. Below
> is my test
> code. Each section is as exact in comparison to the others as I
> can make it.
>
> <CFSET start=GetTickCount()>
> <CFSCRIPT>
>  i=1;
>  While (i LTE 1000){
>   test=i;
>   test2=test+i;
>   i=i+1;
>  }
>  WriteOutput(test);
> </CFSCRIPT>
> <BR>
> While: <CFSET WriteoutPut(gettickcount()-start)>
> <BR>
>
> <CFSET start=GetTickCount()>
> <CFSCRIPT>
>  for(i=1; i LTE 1000; i = i + 1){
>   test=i;
>   test2=test+i;
>  }
>  WriteOutput(test);
> </CFSCRIPT>
>
> <BR>
> For: <CFSET WriteoutPut(gettickcount()-start)>
> <BR>
> <CFSET start=GetTickCount()>
> <CFLOOP from="1" to="1000" index="i">
>  <CFSET test=i>
>  <CFSET test2=test+i>
> </CFLOOP>
> <CFSET WriteOutput(test)>
> <BR>
> CFLoop: <CFSET WriteoutPut(gettickcount()-start)>
> <BR>
>
> Michael Dinowitz
> Publisher: Fusion Authority weekly news alert
> (www.fusionauthority.com/alert)
> Listmaster: CF-Talk, CF-Jobs, Spectra-Talk, Jrun-Talk, etc.
> (www.houseoffusion.com)
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to