Listing 1: ArrayBuild.cfm

<!--- Example showing use of custom tag to test performance --->

<CFQUERY DATASOURCE = "#dsn#" NAME = "query1">
SELECT Answer_id
FROM answer
</CFQUERY>
 

<CF_TIMETEST>
<cfset MyArray = ArrayNew(2)>
<cfloop from = "1" to = "#query1.recordcount#" index = "i">
<cfset MyArray[1][i] = query1.answer_id[i]>
</cfloop>
</CF_TIMETEST>

<!--- tag returns totaltime --->
<CFSET time1 = REQUEST.totaltime>

<CF_TIMETEST>
<cfset MyArray2 = ArrayNew(2)>
<cfloop from = "1" to = "#query1.recordcount#" index = "i">
<cfset ArrayAppend(MyArray2[1], query1.answer_id[i]) >
</cfloop>
</CF_TIMETEST>

<CFSET time2 = REQUEST.totaltime>
<CFOUTPUT>
#time1#ms
<br>
#time2#ms
</CFOUTPUT>
<!--- time1 will be faster --- >

Listing 2: TimeTest.cfm
<!--- Throw an error if no closing tag is detected --->
<CFIF NOT ThisTag.HasEndTag>
<CFABORT SHOWERROR="You need to supply a closing&lt;CF_TimeTest&gt; tag.">
</CFIF>
<CFSET REQUEST.TotalTime = "">
<CFSWITCH expression = "#ThisTag.ExecutionMode#">
<CFCASE value= 'start'>
<CFSET t1 = GetTickCount()>
</CFCASE>
<CFCASE value='end'>
<CFSET REQUEST.TotalTime = GetTickCount() - t1>
</CFCASE>
</CFSWITCH>
<!--- REQUEST.TotalTime is available to the calling tag --->