Execution Times

In reference to the Date Loop, this is a perfect example of when using multiple <cfoutput> on a page can actually slow down the processing of page. (Every so slightly.)

Test Case 1: Loop over date for 1200 months or 100 years with one <cfoutput>. The execution time averages ~360ms.


<cfoutput>
<cfset previousMonth="">
<cfloop index="currentDate" from="#dateAdd('m',-1200,now())#" to="#now()#" step="1">
<cfif month(currentDate) neq previousMonth>
<cfset previousMonth=month(currentDate)>
<br />
#dateformat(currentDate,'mmmm yyyy')#<br />
</cfif>
#day(currentDate)#
<cfif dayofweek(currentDate) is 7>
<br />
</cfif>
</cfloop>
</cfoutput>

Test Case 2: Loop over date for 1200 months or 100 years with a >cfoutput< for each variable that needs outputed. The execution time averages ~375ms.


<cfset previousMonth="">
<cfloop index="currentDate" from="#dateAdd('m',-1200,now())#" to="#now()#" step="1">
<cfif month(currentDate) neq previousMonth>
<cfset previousMonth=month(currentDate)>
<br /><cfoutput>#dateformat(currentDate,'mmmm yyyy')</cfoutput><br />
</cfif>
<cfoutput>#day(currentDate)#</cfoutput>
<cfif dayofweek(currentDate) is 7>
<br />
</cfif>
</cfloop>

Comments
Charlie's Gravatar Hi! Even if I’m a newbie at webservices I found your tutorial very useful, thanks. But I have a very big problem. Whenever I try to contact the site administrator, I am redirected to Music Search http://www.mp3hunting.com Perhaps, I do something wrong...
# Posted By Charlie | 4/13/10 9:08 AM