Hello Damien,

I use the following custom tag to time code blocks:

-------------start---------------------
<!--- timer custom tags to calculate the elapsed time --->
<cfswitch expression="#thistag.executionmode#">
        <cfcase value="start">
                <cfparam name="request.timingArray"
default="#ArrayNew(1)#">
                <cfparam name="attributes.blockName" default="unnamed
block">
                <CFSET StartTime = GetTickCount()>
        </cfcase>
        <cfcase value="end">
                <cfscript>
                        //make struct
                        EndTime = GetTickCount();
                        timeStruct = StructNew();
                        timeStruct.StartTime = StartTime;
                        timeStruct.EndTime = EndTime;
                        timeStruct.blockName = attributes.blockName;
                        timeStruct.time=#Evaluate(EndTime-StartTime)#;
                        ArrayAppend(request.timingarray,timeStruct);
                </cfscript>
        </cfcase>
</cfswitch>
-------------end-----------------------

call it as:
<cf_timer blockname="fooBlock">
.... CFML code here ...
</cf_timer>

and cfdump request.timingArray at the bottom of your page (or in
Onrequestend.cfm)

Regs,
/t

>-----Original Message-----
>From: Damien McKenna [mailto:[EMAIL PROTECTED] 
>Sent: Monday, April 25, 2005 8:47 PM
>To: CF-Talk
>Subject: Script timing?
>
>Is there any way to time how long portions of code take?  I've got a
>loop that seems to take forever and I want to see where the problem is.
>Thanks.
> 
>-- 
>Damien McKenna - Web Developer - [EMAIL PROTECTED]
><mailto:[EMAIL PROTECTED]> 
>The Limu Company - http://www.thelimucompany.com/
><http://www.thelimucompany.com/>  - 407-804-1014
>#include <stdjoke.h>
> 
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204330
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to