Here are some results from 3 of my servers.

NT4.0SP6 4.0.1.0
1000 
While: 47 
1000 
For: 63 
1000 
CFLoop: 62 


NT4.0SP6 4.0.1.0
1000 
While: 47 
1000 
For: 62 
1000 
CFLoop: 63 


NT5.0SP1 4.5.1 SP2
1000 
While: 31 
1000 
For: 47 
1000 
CFLoop: 31 

-----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