ColdFusion code and query execution time tests

Code Execution Time

You can use "GetTickCount()" to calculate the time it takes for a script to run. Insert the following code around the script/code you wish to test:

<!--- Start timing test --->
<cfset tickBegin = GetTickCount()>

<!--- This is where the script/code is you wish to test --->

<!--- Calculate final result --->
<cfset tickEnd = GetTickCount()>
<cfset testTime = tickEnd - tickBegin>

<!--- Report the results of the test --->
<cfoutput>Test time was: #testTime# milliseconds</cfoutput>

Query Execution Time

You can use the variable "cfquery.ExecutionTime" to see how long a certain query takes to execute. After a <CFQUERY> tag, just add this code to your page:

Query Execution time: #cfquery.ExecutionTime#

Add Feedback