>Is CFSCRIPT faster than regular coldfusion coding or is it just easier to
>write so you can get something done faster?

>>Yes. :)

>Faster for variable assignment but slower when looping so I am led to
>believe.

I was chomping at the bit to refute this, in the fine tradition of Usenet
Holy Warriors everywhere.  Perhaps it's my ever-increasing age, but
something told me to check this out for myself before getting my undies in a
bunch.

For the edification of all, the following is the actual code I used to
perform the test, along with the results.

## loopTest1.cfm ##
<cfQuery name="testQuery" datasource="foo">
   SELECT wban, stationname, station_id, state_id, icao_id
   FROM w_stations
</cfQuery>

<cfScript>
   tick1=getTickCount();
   counter = 0;
   for (i=1; i LTE testQuery.recordCount; i=i+1) {
      if (len(testQuery.icao_id[i]) LT 4) {
         counter = counter+1;
         }
      }
   tick2=getTickCount();
   finalTick=tick2 - tick1;
</cfScript>
<cfOutput>#counter#<br>#finalTick#</cfOutput>

## loopTest2.cfm ##

<cfQuery name="testQuery" datasource="foo">
   SELECT wban, stationname, station_id, state_id, icao_id
   FROM w_stations
</cfQuery>

<cfSet tick1=getTickCount()>
<cfSet counter = 0>
<cfloop query="testQuery">
   <cfIf len(testQuery.icao_id) LT 4>
      <cfSet counter = counter+1>
   </cfIf>
</cfLoop>
<cfSet tick2=getTickCount()>
<cfSet finalTick=tick2 - tick1>
<cfOutput>#counter#<br>#finalTick#</cfOutput>

Final results:

Both loops counted to the proper number, 752.

RUN ONCE:
The cfScript method: 485 milliseconds.
The <cfLoop query> method: 141 milliseconds.

RUN 10 TIMES:
cfScript method average: 212 milliseconds.
<cfLoop query> method: 138 milliseconds.

*sigh* live and learn. :)

Brandon Whitaker
[EMAIL PROTECTED]
-------
"It'll get used by the same people using Opera.  People dressed in black
wearing berets."
- Dave Watts, on Mozilla
"The net interprets censorship as damage and routes around it."
- John Gilmore


------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to