DateDiff doesn't support milliseconds

This is a discussion on DateDiff doesn't support milliseconds within the Cold Fusion forums in Application Servers & Tools category; I want to simply output the time the page renders (without making debug info available to public), but amazingly, it seems CF8 lost support in DateDiff for milliseconds (which was the letter 'l' for the datepart) Anyone know of a way to get page execution time?...

Go Back   Application Development Forum > Application Servers & Tools > Cold Fusion

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-22-2008, 06:22 PM
Aegis Kleais
Guest
 
Default DateDiff doesn't support milliseconds

I want to simply output the time the page renders (without making debug info
available to public), but amazingly, it seems CF8 lost support in DateDiff for
milliseconds (which was the letter 'l' for the datepart)

Anyone know of a way to get page execution time?

Reply With Quote
  #2  
Old 08-22-2008, 06:43 PM
Dan Bracuk
Guest
 
Default Re: DateDiff doesn't support milliseconds

gettickcount plus some basic arithmetic.
Reply With Quote
  #3  
Old 08-22-2008, 07:03 PM
Aegis Kleais
Guest
 
Default Re: DateDiff doesn't support milliseconds

I used GetTickCount, but it never matches the execution time when I have debug
out (it may just be because the extra time to process the debug output makes
this different)

There are limitations of where I can use GetTickCount(), because I have to set
it at the start of the request (easy enough, stored in a REQUEST-scope
variable) but then I have to calculate the difference before the page ends (so
the time isn't right) so the variable for the difference exists when I want to
output it (in the footer of the page)

Reply With Quote
  #4  
Old 08-23-2008, 02:26 AM
Adam Cameron
Guest
 
Default Re: DateDiff doesn't support milliseconds

> I used GetTickCount, but it never matches the execution time when I have debug
> out (it may just be because the extra time to process the debug output makes
> this different)


Correct. GetTickCount() will be closer to the mark than what debugging
reports.


> There are limitations of where I can use GetTickCount(), because I have to set
> it at the start of the request (easy enough, stored in a REQUEST-scope
> variable) but then I have to calculate the difference before the page ends (so
> the time isn't right) so the variable for the difference exists when I want to
> output it (in the footer of the page)


Well you'd be needing to do the same thing with dateDiff(), so if there's
an issue, it's not to do with getTickCount().

Can't you just bung the final calculation - and logging thereof - into
OnRequestEnd.cfm?

--
Adam
Reply With Quote
  #5  
Old 08-23-2008, 03:36 AM
BKBK
Guest
 
Default Re: DateDiff doesn't support milliseconds

I used GetTickCount, but it never matches the execution time when
I have debug out (it may just be because the extra time to process the
debug output makes this different)


It is the extra time. You should not confuse the total execution time
with the page execution time. Turn debugging on, open a CFM page and look at
the section Execution Time. You will see that there are separate rows in
the table for the execution time of the page and for the total execution time.

I think the method suggested by Dan and Adam is as accurate as you can get.
Something that goes like this

<cffunction name="onRequestStart">
<cfargument name = "targetPage" type="String" required=true/>
<cfif listlast(arguments.targetPage, "/") is "test.cfm">
<cfset requestBegins=gettickcount()>
</cfif>
</cffunction>

<cffunction name="onRequestEnd">
<cfargument type="String" name = "targetTemplate" required=true/>
<cfif listlast(arguments.targetTemplate, "/") is "test.cfm">
<cfset requestEnds = gettickcount()>
<!--- log or display the time in millisecs, namely,
(requestEnds-requestBegins) --->
</cfif>
</cffunction>



Reply With Quote
  #6  
Old 08-23-2008, 11:28 AM
Aegis Kleais
Guest
 
Default Re: DateDiff doesn't support milliseconds

But if I determine the page render time in the onRequestEnd, I cannot output that information to the screen such as a "Page rendered in xxx" string.
Reply With Quote
  #7  
Old 08-23-2008, 12:16 PM
BKBK
Guest
 
Default Re: DateDiff doesn't support milliseconds

But if I determine the page render time in the onRequestEnd, I cannot output that information to the screen such as a "Page rendered in xxx" string

You can. Try it?


Reply With Quote
  #8  
Old 08-23-2008, 02:44 PM
Aegis Kleais
Guest
 
Default Re: DateDiff doesn't support milliseconds

Well, I'll give it a shot. Gonna set start time in onRequestStart and
calculate end time in onRequestEnd and then try to output that value in the
page called in the onRequest. I'll scope the calculated value and store it in
the REQUEST scope and see if it flies.

Gotta wait til Monday to do it though - my localhost at home with CF8 is
broken. Will try it at work.

Reply With Quote
  #9  
Old 08-24-2008, 04:00 AM
BKBK
Guest
 
Default Re: DateDiff doesn't support milliseconds

Leave onRequest out of it. In fact, comment it out, unless you have use for it.
It works like a cfsavecontent for the current page, enabling you to manipulate
its contents. It therefore has no place here.

Just set the start-time in onRequestStart and log or display the execution
time in onRequestEnd. I would also stick to the variables scope. I don't expect
the request scope defined in onRequestStart to carry over into onRequestEnd.



Reply With Quote
  #10  
Old 08-25-2008, 09:11 AM
Aegis Kleais
Guest
 
Default Re: DateDiff doesn't support milliseconds

Well, right now it's not working.

My current setup is that in onRequestStart I have the code to set the start
time (tried saving it in REQUEST scope and VARIABLES scope) In the onRequest
scope, I have custom code I wrote that promotes SES (Search Engine Safe) page
builds, allowing me to call pages like:

http://www.domain.com/filename/variable/variable/etc

And in onRequestEnd, I made the calculation and stored it in both REQUEST and
VARIABLES scopes. In the onRequest, after the pathing is built and the page
intended is determined, that template is included. My pages are built via a
template.cfc component which I invoke through CreateObject().

The page is built as such:

REQUEST.objTemplate.writeHeader()
(Included Template Data here)
REQUEST.objTemplate.writeFooter()

The writeFooter function of my objTemplate component has code which displays
the execution time, and as of all tests so far, it says the variable
(intExecutionTime) does not exist in REQUEST scope (or VARIABLES)

Should I move all my code from onRequest into the onRequestStart and leave
onRequest empty?

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 07:13 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.