cfStopWatch on Railo

After I found the Ternary Operator on Railo I've decided to have a look over the Tags documentation, and Functions documentation viewer on Railo Wiki.

Then I came across CFStopWatch. It works like CFTimer in that its used to determine how long it takes for a block of code to execute. The difference is that CFStopWatch stores the time to execute in a variable so you can reference it later. It works by wrapping the tags around the code block you want to execute and setting the time to a variable:

[sourcecode language="plain"] <cfstopwatch label="myLabel" variable="var" > CFML logic goes here <!--- pause for 1 second ---> <cfsleep time="1000"/> </cfstopwatch>

<cfoutput><p>Your code took #var# milliseconds to run</p></cfoutput> [/sourcecode]

Running the above code will output

CFML logic goes here

Your code took 1000 milliseconds to run

I can see me using this when running code blocks which I know might take ages, you could write of the time to a log or even send an email.

Posted: 19-Jul-2009

View: 748

Permalink: here

Comments

in the links to the documentation you provided, it doesn't say anything about these tags only executing when debugging is turned on? am i missing something?

#1 tony petruzzi
20/Jul/09 3:15 PM

I wrote a tag called back in 1999 that does the same thing...

#2 Dan G. Switzer, II
20/Jul/09 3:18 PM

comment5,

#3 iertunjvd
26/Dec/09 1:19 AM