What do make of this then???
CFLOOP is (fairly substantially) quicker when you have 1,000,000
repetitions...

1,000,000 repetitions:
====================
CF-34781
While - 50079
do-50391

100,000 repetitions:
===================
CF-3360
While - 1859
do-1813 

10,000 repetitions:
==================
CF-343
While - 172
do-188

1,000 repetitions:
====================
CF-46
While - 16
do-16

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 13 March 2001 18:26
To: CF-Talk
Subject: (Review) Conditional loops


I just did some more tests and I've got some more interesting results. The
test 
was to compare conditional loops between the CFLOOP and the two conditional 
loops in CFSCRIPT (while and do-while). My tests showed that the CFSCRIPT 
statments were about twice as fast as the CFLOOP statment. This was my
expected 
results. It looks like the only loop that is faster outside of CFSCRIPT is
the 
for loop (from-to). 
For those who want to test my code and see my results, I've pasted it below.
To 
do a real test, try a loop count of 1000, 10000 or even higher. 

<CFSET loopcount=0>
<CFSET start=GetTickCount()>
<CFLOOP condition="loopcount LTE 1000">
        <CFSET loopcount=loopcount+1>
</CFLOOP>
<CFSET cf=gettickcount()-start>
<BR>

<CFSET loopcount=0>
<CFSET start=GetTickCount()>
<CFSCRIPT>
while (loopcount LTE 1000)
        loopcount=loopcount+1;
</CFSCRIPT>
<CFSET wh=gettickcount()-start>
<BR>

<CFSET loopcount=0>
<CFSET start=GetTickCount()>
<CFSCRIPT>
do
        loopcount=loopcount+1;
while (loopcount LTE 1000);
</CFSCRIPT>
<CFSET do=gettickcount()-start>

<HR>
<CFOUTPUT>
CF-#cf#<BR>
While - #wh#<BR>
do-#do#
</CFOUTPUT>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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