This chapter suggests a number of techniques to improve application performance, and you will come across others while learning about ColdFusion. How can you tell whether they are helping in your application? As you'll read in the following subsections, a number of ColdFusion tools are available to help with this task.
In ColdFusion Administrator, you can select the Report Execution Times checkbox under Debugging. This option displays the total time of page processing and execution. By recording a page's execution times, you could see whether changes to the page help improve performance.
To determine the execution time of specific lines of code, wrap that code within <cftimer> tags. Results will be displayed in the debug output (default), inline, in HTML comments, or in generated page outlines (depending on the type specified):
<cftimer label="some label" type="outline"> Code to time </cftimer>
<cfset Start=GetTickCount()> Code to time <cfset End=GetTickCount()> <cfoutput>The time to process is: #End-Start#</cfoutput>
Improving Perceived Response Time
After each application page, the database, and the server environment have been
The <CFFLUSH> tag can help accelerate users' perceived response time. With this tag, you can flush incremental output to browsers so that users have a visual indication that their request is successful and will be completed soon.
Before ColdFusion can flush data, it must compile the data to return. A long-running query must complete before data can be flushed. Some queries might be too long for the
tag to help with perception of performance. In those cases, it's best to give users a "
The <cfflush> tag takes one optional attribute, INTERVAL , which is the number of bytes to collect and flush to a browser at one time. You should use INTERVAL only when a large amount of output will be sent to the client; it is used like this:
<cfflush interval="integer number of bytes">
interval data will be flushed automatically whenever the specified number of bytes is in the output buffer (additional <cfflush> tags are not required).
You shouldn't use
when generating complete HTML pages. Doing so could cause partial data to be flushedincomplete DHTML, for example. If the
You should use <cfflush> when you think you can incrementally flush large amounts of data back to the user and help with perceived response time.
Because an HTML header is the first component to be flushed, errors occur if any
All these errors, except for <cfcookie> , can be caught and handled with the <cfcatch type="template"> tag. Cookie errors can be caught with <CFCATCH type="any"> .