CFTIMER - Little things in ColdFusion 7

coldfusion

I am digging the new cftimer tag in ColdFusion MX 7.

In previous versions when you want to time how long something takes, you would do something like this:

<cfset tick = GetTickCount()>
  run your code here...
<cfset tock = GetTickCount()>
<cfset time = tock-tick>
<cfoutput>it took #time#ms</cfoutput>

With the new cftimer you just need to wrap your code with the CFTIMER tag (and turn on the display Timer Information option in ColdFusion Administrator)

<cftimer label="Google Download Timer" type="outline">
	<cfhttp method="get" url="http://www.google.com/"></cfhttp>
	<cfoutput>downloaded google</cfoutput>
</cftimer>

And it will output something like this:

Google Download Timer: 62ms downloaded google

Note that your browser must support the fieldset and legend tags for this to show up properly with cftimer type="outline"

There are other output types you can use: inline which just displays the timer at the position of the </cftimer> tag, the comment type inserts the timer in an HTML comment, eg: <!-- Google Download Timer: 62ms -->, and the debug type displays the timers at the bottom of the page with the debug output.



Related Entries

1 person found this page useful, what do you think?

 Download FuseGuard WAF for ColdFusion

Trackbacks

Trackback Address: 227/2E99EF23592508A5D68901A834EBC93A

Comments

On 02/11/2005 at 6:43:35 PM EST johnb wrote:
1
I tried this tag myself the other day - it's a pity the resultant timing isn't available as a variable too - means you still have to use gettickcount() if you want to log the timings of execution etc

Post a Comment




  



Spell Checker by Foundeo

Recent Entries



foundeo


did you hack my cf?