A few days ago I was working on an update to ColdFire (mainly support for CFTIMER), when I ran into an interesting problem. When you use CFTIMER, you have a few options for how to display the timer information. Those options are inline, outline, comment, and debug. I wanted to ensure that ColdFire only picked up on timer information that used type=debug. Turned out I didn't need to worry about it. Internally - ColdFusion didn't record any cftimer call that wasn't type=debug. But I kept my inline cftimer test in so I could be sure it was acting like I thought it would.
But then ColdFire simply stopped working. I wasn't sure why - but then I realized that ColdFire thought a flush had happened! I had certainly not ran a cfflush (I have a separate test page for that), so I wasn't sure what was wrong.
Turns out that when you use cftimer/type=inline, ColdFusion itself performs a flush! You can see this yourself by running this code:
<cftimer type="inline" label="foo">
</cftimer>
<cfset thread = CreateObject("java", "java.lang.Thread")>
<cfset thread.sleep(5000)>
ColdFusion will quickly display foo, and then execute the sleep. This was also confirmed by a friend at Adobe.
So while obviously this isn't a big huge deal (just one more thing to document for ColdFire), it may bite you if you try to do a cfheader call after a cftimer call. If you do, you will get:
Failed to add HTML header.ColdFusion was unable to add the header you specified to the output stream. This is probably because you have already used a CFFLUSH tag in your template,or buffered output is turned off
Archived Comments
This has been requested for an addition to the livedocs entry for awhile I think. I remember the first time I heard about it was almost a year ago now. The buffer is definitely being sent to the client on inline or comment. Hopefully Scorpio addresses it in the livedocs.
Mike Schierbel's post (9 months apparently ... not a yr :P )
http://www.schierberl.com/c...
Slightly off topic, I never understood why cftimer didn't have a "variable" attribute. =(
DK - Nice to know it wasn't just me bugged by this.
Joe - Why? You aren't timing a variable, but the amount of time it takes to run a block of code.
[quote]
Joe - Why? You aren't timing a variable, but the amount of time it takes to run a block of code.
[/quote]
So you can have several of them on a page and display them at the bottom of the page or store them in a persistent scope somewhere or even in the database.
Hmmm. I can maybe see that. Probably _any_ tag that outputs should let you save to a variable instead.
Joe,
I just posted a custom tag alternative that I use instead of cftimer. And it does have a "variable" attribute.
http://www.cfchris.com/cfch...