Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

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.

Comments Comments (3) | Print Print | Send Send | 299 Views

(Comment Moderation is enabled. Your comment will not appear until approved.)
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?
I wrote a tag called back in 1999 that does the same thing...
comment5,
BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .