1. <!---
  2. **
  3. * CF5 Debugging Output
  4. *
  5. * Copyright (c) 2001 Macromedia. All Rights Reserved.
  6. * DO NOT REDISTRIBUTE THIS SOFTWARE IN ANY WAY WITHOUT THE EXPRESSED
  7. * WRITTEN PERMISSION OF MACROMEDIA.
  8. --->
  9. <cfif IsDebugMode()>
  10. <cfsilent>
  11. <cfset startTime = getTickCount()>
  12. <cfscript>
  13.     formEncoding = getEncoding("FORM");
  14.     urlEncoding = getEncoding("URL");
  15.     setEncoding("FORM", formEncoding);
  16.     setEncoding("URL", urlEncoding);
  17. </cfscript>
  18. </cfsilent>
  19. <!--- Localized strings --->
  20. <cfset undefined = "">
  21.     <!--- Use the debugging service to check options --->
  22.     <cftry>
  23.         <cfobject action="CREATE" type="JAVA" class="coldfusion.server.ServiceFactory" name="factory">
  24.         <cfset cfdebugger = factory.getDebuggingService()>
  25.         <cfcatch type="Any"></cfcatch>
  26.     </cftry>
  27.     <!--- Load the debugging service's event table --->
  28.     <cfset qEvents = cfdebugger.getDebugger().getData()>
  29.     <!--- Produce the filtered event queries --->
  30.     <!--- EVENT: Templates --->
  31.     <cftry>
  32.         <cfquery dbType="query" name="cfdebug_templates" debug="false">
  33.             SELECT template, parent, Sum(endTime - StartTime) AS et
  34.             FROM qEvents
  35.             WHERE type = 'Template'
  36.             GROUP BY template, parent
  37.             ORDER BY et DESC
  38.         </cfquery>
  39. <!--- added by Aaron Longnion, 2007-03-24, so we can see the order files ran --->
  40.         <cfquery name="cfdebug_orderedTemplates" dbtype="query" debug="false">
  41.             SELECT
  42.                 line,
  43.                 parent,
  44.                 template
  45.             FROM
  46.              qEvents
  47.             WHERE
  48.              type = 'Template'
  49.             ORDER BY
  50.              starttime DESC
  51.         </cfquery>
  52.         <cfscript>
  53.             if( cfdebug_templates.recordCount eq 1 and len(trim(cfdebug_templates.et)) )
  54.             {
  55.                 querySetCell(cfdebug_templates, "et", "0", 1);
  56.             }
  57.         </cfscript>
  58.         <cfcatch type="Any">
  59.             <cfscript>
  60.                 cfdebug_templates = queryNew('template, parent, et');
  61.             </cfscript>
  62.         </cfcatch>
  63.     </cftry>
  64.     <!--- EVENT: SQL Queries --->
  65.     <cftry>
  66.         <cfquery dbType="query" name="cfdebug_queries" debug="false">
  67.             SELECT *, (endTime - startTime) AS executionTime
  68.             FROM qEvents
  69.             WHERE type = 'SqlQuery'
  70.         </cfquery>
  71.         <cfscript>
  72.             if( cfdebug_queries.recordCount eq 1 and len(trim(cfdebug_queries.executionTime)) )
  73.             {
  74.                 querySetCell(cfdebug_queries, "executionTime", "0", 1);
  75.             }
  76.         </cfscript>
  77.         <cfcatch type="Any">
  78.             <cfscript>
  79.                 cfdebug_queries = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL, et');
  80.             </cfscript>
  81.         </cfcatch>
  82.     </cftry>
  83.     <!--- EVENT: Object Queries --->
  84.     <cftry>
  85.         <cfquery dbType="query" name="cfdebug_cfoql" debug="false">
  86.             SELECT *, (endTime - startTime) AS executionTime
  87.             FROM qEvents
  88.             WHERE type = 'ObjectQuery'
  89.         </cfquery>
  90.         <cfscript>
  91.             if( cfdebug_cfoql.recordCount eq 1 and len(trim(cfdebug_cfoql.executionTime)) )
  92.             {
  93.                 querySetCell(cfdebug_cfoql, "executionTime", "0", 1);
  94.             }
  95.         </cfscript>
  96.         <cfcatch type="Any">
  97.             <cfscript>
  98.                 cfdebug_cfoql = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  99.             </cfscript>
  100.         </cfcatch>
  101.     </cftry>
  102.     <!--- EVENT: Stored Procedures --->
  103.     <cftry>
  104.         <cfquery dbType="query" name="cfdebug_storedproc" debug="false">
  105.             SELECT *, (endTime - startTime) AS executionTime
  106.             FROM qEvents
  107.             WHERE type = 'StoredProcedure'
  108.         </cfquery>
  109.         <cfscript>
  110.             if( cfdebug_storedproc.recordCount eq 1 and len(trim(cfdebug_storedproc.executionTime)) )
  111.             {
  112.                 querySetCell(cfdebug_storedproc, "executionTime", "0", 1);
  113.             }
  114.         </cfscript>
  115.         <cfcatch type="Any">
  116.             <cfscript>
  117.                 cfdebug_storedproc = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  118.             </cfscript>
  119.         </cfcatch>
  120.     </cftry>
  121.     <!--- EVENT: Trace Points --->
  122.     <cftry>
  123.         <cfquery dbType="query" name="cfdebug_trace" debug="false">
  124.             SELECT *
  125.             FROM qEvents
  126.             WHERE type = 'Trace'
  127.         </cfquery>
  128.         <cfcatch type="Any">
  129.             <cfscript>
  130.                 cfdebug_trace = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  131.             </cfscript>
  132.         </cfcatch>
  133.     </cftry>
  134.     <!--- EVENT: CFTimer Points --->
  135.     <cftry>
  136.         <cfquery dbType="query" name="cfdebug_timer" debug="false">
  137.             SELECT *
  138.             FROM qEvents
  139.             WHERE type = 'CFTimer'
  140.         </cfquery>
  141.         <cfcatch type="Any">
  142.             <cfscript>
  143.                 cfdebug_timer = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  144.             </cfscript>
  145.         </cfcatch>
  146.     </cftry>
  147.     <!--- EVENT: Locking Warning Points --->
  148.     <cftry>
  149.         <cfquery dbType="query" name="cfdebug_lock" debug="false">
  150.             SELECT *
  151.             FROM qEvents
  152.             WHERE type = 'LockWarning'
  153.         </cfquery>
  154.         <cfcatch type="Any">
  155.             <cfscript>
  156.                 cfdebug_lock = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  157.             </cfscript>
  158.         </cfcatch>
  159.     </cftry>
  160.     <!--- EVENT: Exceptions --->
  161.     <cftry>
  162.         <cfquery dbType="query" name="cfdebug_ex" debug="false">
  163.             SELECT *
  164.             FROM qEvents
  165.             WHERE type = 'Exception'
  166.         </cfquery>
  167.         <cfcatch type="Any">
  168.             <cfscript>
  169.                 cfdebug_ex = queryNew('ATTRIBUTES, BODY, CACHEDQUERY, CATEGORY, DATASOURCE, ENDTIME, EXECUTIONTIME, LINE, MESSAGE, NAME, PARENT, PRIORITY, RESULT, ROWCOUNT, STACKTRACE, STARTTIME, TEMPLATE, TIMESTAMP, TYPE, URL');
  170.             </cfscript>
  171.         </cfcatch>
  172.     </cftry>
  173.     <!--- Establish Section Display Flags --->
  174.     <cfparam name="displayDebug" default="false" type="boolean"><!--- ::    display the debug time     :: --->
  175.     <cfparam name="bGeneral" default="false" type="boolean">
  176.     <cfparam name="bFoundExecution" default="false" type="boolean">
  177.     <cfparam name="bFoundTemplates" default="false" type="boolean">
  178.     <cfparam name="bFoundExceptions" default="false" type="boolean">
  179.     <cfparam name="bFoundSQLQueries" default="false" type="boolean">
  180.     <cfparam name="bFoundObjectQueries" default="false" type="boolean">
  181.     <cfparam name="bFoundStoredProc" default="false" type="boolean">
  182.     <cfparam name="bFoundTrace" default="false" type="boolean">
  183.     <cfparam name="bFoundTimer" default="false" type="boolean">
  184.     <cfparam name="bFoundLocking" default="false" type="boolean">
  185.     <cfparam name="bFoundScopeVars" default="false" type="boolean">
  186.     <cftry>
  187.         <cfscript>
  188.             bFoundTemplates = cfdebugger.check("Template");
  189.             if( bFoundTemplates )
  190.             { displayDebug=true; }
  191.             if ( isDefined("cfdebugger.settings.general") and cfdebugger.settings.general )
  192.             { bGeneral = true; displayDebug=true; }
  193.             if (IsDefined("cfdebug_ex") AND cfdebug_ex.recordCount GT 0) { bFoundExceptions = true; displayDebug=true; }
  194.             else { bFoundExceptions = false; }
  195.             if (IsDefined("cfdebug_queries") AND cfdebug_queries.RecordCount GT 0) { bFoundSQLQueries = true; displayDebug=true; }
  196.             else { bFoundSQLQueries = false; }
  197.             if (IsDefined("cfdebug_cfoql") AND cfdebug_cfoql.RecordCount GT 0) { bFoundObjectQueries = true; displayDebug=true; }
  198.             else { bFoundObjectQueries = false; }
  199.             if (IsDefined("cfdebug_storedproc") AND cfdebug_storedproc.RecordCount GT 0) { bFoundStoredProc = true; displayDebug=true; }
  200.             else { bFoundStoredProc = false; }
  201.             if (IsDefined("cfdebug_trace") AND cfdebug_trace.recordCount GT 0) { bFoundTrace = true; displayDebug=true; }
  202.             else { bFoundTrace = false; }
  203.             if (IsDefined("cfdebug_timer") AND cfdebug_timer.recordCount GT 0) { bFoundTimer = true; displayDebug=true; }
  204.             else { bFoundTimer = false; }
  205.             if (IsDefined("cfdebug_lock") AND cfdebug_lock.recordCount GT 0) { bFoundLocking = true; displayDebug=true; }
  206.             else { bFoundLocking = false; }
  207.             if (IsDefined("cfdebugger") AND cfdebugger.check("Variables")) { bFoundScopeVars = true; displayDebug=true; }
  208.             else { bFoundScopeVars = false; }
  209.         </cfscript>
  210.         <cfcatch type="Any"></cfcatch>
  211.     </cftry>
  212. <cfsetting enablecfoutputonly="Yes">
  213. <cfif displayDebug>
  214. <cfoutput>
  215. </td></td></td></th></th></th></tr></tr></tr></table></table></table></a></abbrev></acronym></address></applet></au></b></banner></big></blink></blockquote></bq></caption></center></cite></code></comment></del></dfn></dir></div></div></dl></em></fig></fn></font></form></frame></frameset></h1></h2></h3></h4></h5></h6></head></i></ins></kbd></listing></map></marquee></menu></multicol></nobr></noframes></noscript></note></ol></p></param></person></plaintext></pre></q></s></samp></script></select></small></strike></strong></sub></sup></table></td></textarea></th></title></tr></tt></u></ul></var></wbr></xmp>
  216. <style type="text/css">
  217. .cfdebug
  218. {
  219.     color:black;
  220.     background-color:white;
  221.     font-family:"Times New Roman", Times, serif;
  222.     font-size:small;
  223.     text-align: left;
  224. }
  225. .cfdebuglge
  226. {
  227.     color:black;
  228.     background-color:white;
  229.     font-family:"Times New Roman", Times, serif;
  230.     font-size:medium;
  231. }
  232. a.cfdebuglink {color:blue; background-color:white }
  233. </style>
  234. <table class="cfdebug" bgcolor="white">
  235. <tr>
  236.     <td>
  237. </cfoutput>
  238. </cfif>
  239. <cfif bGeneral>
  240. <cfoutput>
  241.     <cftry>
  242.         <p class="cfdebug"><hr/>
  243.         <b class="cfdebuglge"><a name="cfdebug_top">Debugging Information</a></b>
  244.         <table class="cfdebug">
  245.         <tr>
  246.             <td class="cfdebug" nowrap>#server.coldfusion.productname# #server.coldfusion.productlevel#</td>
  247.             <td class="cfdebug">#server.coldfusion.productversion#</td>
  248.         </tr>
  249.         <tr>
  250.             <td class="cfdebug" nowrap> Template </td>
  251.             <td class="cfdebug">#xmlFormat(CGI.Script_Name)#</td>
  252.         </tr>
  253.         <tr>
  254.             <td class="cfdebug" nowrap> Time Stamp </td>
  255.             <td class="cfdebug">#DateFormat(Now())# #TimeFormat(Now())#</td>
  256.         </tr>
  257.         <tr>
  258.             <td class="cfdebug" nowrap> Locale </td>
  259.             <td class="cfdebug">#GetLocale()#</td>
  260.         </tr>
  261.         <tr>
  262.             <td class="cfdebug" nowrap> User Agent </td>
  263.             <td class="cfdebug">#CGI.HTTP_USER_AGENT#</td>
  264.         </tr>
  265.         <tr>
  266.             <td class="cfdebug" nowrap> Remote IP </td>
  267.             <td class="cfdebug">#CGI.REMOTE_ADDR#</td>
  268.         </tr>
  269.         <tr>
  270.             <td class="cfdebug" nowrap> Host Name </td>
  271.             <td class="cfdebug">#CGI.REMOTE_HOST#</td>
  272.         </tr>
  273.         </table>
  274.         </p>
  275.         <cfcatch type="Any"></cfcatch>
  276.     </cftry>
  277. </cfoutput>
  278. </cfif>
  279. <!--- Template Stack and Executions Times --->
  280. <cfif bFoundTemplates>
  281.     <!--- Total Execution Time of all top level pages --->
  282.     <cfquery dbType="query" name="cfdebug_execution" debug="false">
  283.     SELECT (endTime - startTime) AS executionTime
  284.     FROM qEvents
  285.     WHERE type = 'ExecutionTime'
  286.     </cfquery>
  287.     <!--- ::
  288.         in the case that no execution time is recorded.
  289.         we will add a value of -1 so we know that a problem exists but the template continues to run properly.
  290.         :: --->
  291.     <cfif not cfdebug_execution.recordCount>
  292.         <cfscript>
  293.             queryAddRow(cfdebug_execution);
  294.             querySetCell(cfdebug_execution, "executionTime", "-1");
  295.         </cfscript>
  296.     </cfif>
  297.     <cfquery dbType="query" name="cfdebug_top_level_execution_sum" debug="false">
  298.         SELECT sum(endTime - startTime) AS executionTime
  299.          FROM qEvents
  300.         WHERE type = 'Template' AND parent = ''
  301.     </cfquery>
  302. <!--- File not found will not produce any records when looking for top level pages --->
  303. <cfif cfdebug_top_level_execution_sum.recordCount and len(trim(cfdebug_top_level_execution_sum.executionTime[1])) gt 0>
  304. <cfset time_other = Max(cfdebug_execution.executionTime - val(cfdebug_top_level_execution_sum.executionTime), 0)>
  305. <cfoutput>
  306.             <style type="text/css">
  307. .template
  308. {    color: black;
  309.     font-family: "Times New Roman", Times, serif;
  310.     font-weight: normal; }
  311. .template_overage
  312. {    color: red;
  313.     background-color: white;
  314.     font-family: "Times New Roman", Times, serif;
  315.     font-weight: bold; }
  316. </style>
  317. </cfoutput>
  318. <cfif cfdebugger.settings.template_mode EQ "tree">
  319. <cfset a = arrayNew(1)>
  320. <cfloop query="qEvents">
  321. <cfscript>
  322. // in cannot convert the value "" to a boolean for cachedquery column
  323. // SELECT stacktrace will result in Query Of Queries runtime error.
  324. // Failed to get meta_data for columnqEvents.stacktrace .
  325. // Was told I need to define meta data for debugging event table similar to <cfldap>
  326. if( qEvents.type eq "template" ) {
  327. st = structNew();
  328. st.StackTrace = qEvents.stackTrace;
  329. st.template = qEvents.template;
  330. st.startTime = qEvents.starttime;
  331. st.endTime = qEvents.endtime;
  332. st.parent = qEvents.parent;
  333. st.line = qEvents.line;
  334. arrayAppend(a, st);
  335. }
  336. </cfscript>
  337. </cfloop>
  338. <cfset qTree = queryNew("template,templateId,parentId,duration,line")>
  339. <cfloop index="i" from="1" to="#arrayLen(a)#">
  340. <cfset childidList = "">
  341. <cfset parentidList = "">
  342. <cfloop index="x" from="#arrayLen(a[i].stacktrace.tagcontext)#" to="1" step="-1">
  343. <cfscript>
  344. if( a[i].stacktrace.tagcontext[x].id NEQ "CF_INDEX" ) {
  345. // keep appending the line number from the template stack to form a unique id
  346. childIdList = listAppend(childIdList, a[i].stacktrace.tagcontext[x].line);
  347. if( x eq 1 ) {
  348. parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].template);
  349. } else {
  350. parentIdList = listAppend(parentIdList, a[i].stacktrace.tagcontext[x].line);
  351. }
  352. }
  353. </cfscript>
  354. </cfloop>
  355. <cfscript>
  356. // template is the last part of the unique id...12,5,17,c:\wwwroot\foo.cfm
  357. // if we don't remove the "CFC[" prefix, then the parentId and childId relationship
  358. // will be all wrong
  359. startToken = "CFC[ ";
  360. endToken = " | ";
  361. thisTemplate = a[i].template;
  362. startTokenIndex = FindNoCase(startToken, thisTemplate, 1);
  363. if( startTokenIndex NEQ 0 ) {
  364. endTokenIndex = FindNoCase(endToken, thisTemplate, startTokenIndex);
  365. thisTemplate = Trim(Mid(thisTemplate,Len(startToken),endTokenIndex-Len(startToken)));
  366. }
  367. childIdList = listAppend(childIdList, thisTemplate);
  368. queryAddRow(qTree);
  369. querySetCell(qTree, "template", a[i].template);
  370. querySetCell(qTree, "templateId", childIdList);
  371. querySetCell(qTree, "parentId", parentIdList);
  372. querySetCell(qTree, "duration", a[i].endtime - a[i].starttime);
  373. querySetCell(qTree, "line", a[i].line);
  374. </cfscript>
  375. </cfloop>
  376. <cfset stTree = structNew()>
  377. <cfloop query="qTree">
  378. <cfscript>
  379. // empty parent assumed to be top level with the exception of application.cfm
  380. if( len(trim(parentId)) eq 0 ){
  381. parentId = 0;
  382. }
  383. stTree[parentId] = structNew();
  384. stTree[parentId].templateId = qTree.templateId;
  385. stTree[parentId].template = qTree.template;
  386. stTree[parentId].duration = qTree.duration;
  387. stTree[parentId].line = qTree.line;
  388. stTree[parentId].children = arrayNew(1);
  389. </cfscript>
  390. </cfloop>
  391. <cfloop query="qTree">
  392. <cfscript>
  393. stTree[templateId] = structNew();
  394. stTree[templateId].templateId = qTree.templateId;
  395. stTree[templateId].template = qTree.template;
  396. stTree[templateId].duration = qTree.duration;
  397. stTree[templateId].line = qTree.line;
  398. stTree[templateId].children = arrayNew(1);
  399. </cfscript>
  400. </cfloop>
  401. <cfloop query="qTree">
  402. <cfscript>
  403. arrayAppend(stTree[parentId].children, stTree[templateId]);
  404. </cfscript>
  405. </cfloop>
  406. <cfquery dbType="query" name="topNodes" debug="false">
  407. SELECT parentId, templateid
  408. FROM qTree
  409. WHERE parentId = ''
  410. </cfquery>
  411. <cfoutput>
  412. <p class="cfdebug"><hr/><b class="cfdebuglge">Execution Time</b></p>
  413. </cfoutput>
  414. <cfoutput query="topNodes">
  415. #drawTree(stTree,-1,topNodes.templateid,cfdebugger.settings.template_highlight_minimum)#
  416. </cfoutput>
  417. <cfoutput><p class="template">
  418. (#time_other# ms) STARTUP, PARSING, COMPILING, LOADING, &amp; SHUTDOWN<br />
  419. (#cfdebug_execution.executionTime# ms) TOTAL EXECUTION TIME<br />
  420. <font color="red"><span class="template_overage">red = over #cfdebugger.settings.template_highlight_minimum# ms execution time</span></font>
  421. </p></cfoutput>
  422. <cfelse>
  423.     <cftry>
  424. <!--- added by Aaron Longnion, 2007-03-24, so we can see the order files ran --->
  425.         <cfoutput>
  426.              <p class="cfdebug"><hr/><b class="cfdebuglge">Ordered Templates (DESC)</b></p>
  427.      <table border="1" cellpadding="2" cellspacing="0" class="cfdebug">
  428.      <tr>
  429.                         <td class="cfdebug" align="center"><b>Line</b></td>
  430.                         <td class="cfdebug" align="center"><b>Template</b></td>
  431.                         <td class="cfdebug" align="center"><b>Parent</b></td>
  432.                     </tr>
  433. </cfoutput>
  434.         <cfoutput query="cfdebug_orderedTemplates">
  435.             <cfif Len(cfdebug_orderedTemplates.Parent)
  436.              AND cfdebug_orderedTemplates.Template NEQ cfdebug_orderedTemplates.Parent>
  437.                 <cfset orderedTemplate = Replace(cfdebug_orderedTemplates.Template, cfdebug_orderedTemplates.Parent, "")>
  438.                 <cfset orderedTemplate = Replace(orderedTemplate, "from", "")>
  439.             <cfelse>
  440. <cfset orderedTemplate = cfdebug_orderedTemplates.Template>
  441. </cfif>
  442.             <tr>
  443.                         <td class="cfdebug" align="center"><b>#cfdebug_orderedTemplates.Line#</b></td>
  444.                         <td class="cfdebug" align="center"><b>#orderedTemplate#</b></td>
  445.                         <td class="cfdebug" align="center"><b>#cfdebug_orderedTemplates.Parent#</b></td>
  446.                     </tr>
  447.         </cfoutput>
  448.         <cfoutput>
  449. </table>
  450. </cfoutput>
  451. <cfoutput>
  452. <p class="cfdebug"><hr/><b class="cfdebuglge">Execution Time</b></p>
  453. </cfoutput>
  454.          <cfquery dbType="query" name="cfdebug_templates_summary" debug="false">
  455.      SELECT template, Sum(endTime - startTime) AS totalExecutionTime, count(template) AS instances
  456.      FROM qEvents
  457.      WHERE type = 'Template'
  458.      group by template
  459.      order by totalExecutionTime DESC
  460. </cfquery>
  461. <cfoutput>
  462. <table border="1" cellpadding="2" cellspacing="0" class="cfdebug">
  463. <tr>
  464.                     <td class="cfdebug" align="center"><b>Total Time</b></td>
  465.                     <td class="cfdebug" align="center"><b>Avg Time</b></td>
  466.                     <td class="cfdebug" align="center"><b>Count</b></td>
  467.                     <td class="cfdebug"><b>Template</b></td>
  468.                 </tr>
  469. </cfoutput>
  470. <cftry>
  471. <cfoutput query="cfdebug_templates_summary">
  472. <cfset templateOutput = template>
  473. <cfset templateAverageTime = Round(totalExecutionTime / instances)>
  474. <cfif template EQ ExpandPath(cgi.script_name)>
  475. <cfset templateOutput =
  476. "<b>" & template & "</b>">
  477.                              <cfif templateAverageTime GT cfdebugger.settings.template_highlight_minimum>
  478. <cfset templateOutput = "<font color='red'><span class='template_overage'>" & template & "</span></font>">
  479. <cfset templateAverageTime = "<font color='red'><span class='template_overage'>" & templateAverageTime & "</span></font>">
  480.                                  <cfset totalTime = "<font color='red'><span class='template_overage'>" & totalExecutionTime & "</span></font>">
  481. </cfif>
  482. <cfelse>
  483. <cfif templateAverageTime GT cfdebugger.settings.template_highlight_minimum>
  484. <cfset templateOutput = "<font color='red'><span class='template_overage'>" & template & "</span></font>">
  485. <cfset templateAverageTime = "<font color='red'><span class='template_overage'>" & templateAverageTime & "</span></font>">
  486.                                  <cfset totalTime = "<font color='red'><span class='template_overage'>" & totalExecutionTime & "</span></font>">
  487. </cfif>
  488. </cfif>
  489. <tr>
  490.                             <cfif isDefined("totalTime") and len(trim(totalTime))>
  491.                                 <td align="right" class="cfdebug" nowrap>#totalTime# ms</td>
  492.                                 <cfset totalTime = "">
  493.                             <cfelse>
  494.      <td align="right" class="cfdebug" nowrap>#totalExecutionTime# ms</td>
  495.                             </cfif>
  496. <td align="right" class="cfdebug" nowrap>#templateAverageTime# ms</td>
  497. <td align="center" class="cfdebug" nowrap>#instances#</td>
  498. <td align="left" class="cfdebug" nowrap>#templateOutput#</td>
  499. </tr>
  500. </cfoutput>
  501.     <cfcatch type="Any"></cfcatch>
  502. </cftry>
  503. <cfoutput>
  504. <tr>
  505.                     <td align="right" class="cfdebug" nowrap><i>#time_other# ms</i></td><td colspan=2>&nbsp;</td>
  506. <td align="left" class="cfdebug"><i>STARTUP, PARSING, COMPILING, LOADING, &amp; SHUTDOWN</i></td>
  507.                 </tr>
  508. <tr>
  509.                     <td align="right" class="cfdebug" nowrap><i>#cfdebug_execution.executionTime# ms</i></td><td colspan=2>&nbsp;</td>
  510. <td align="left" class="cfdebug"><i>TOTAL EXECUTION TIME</i></td>
  511.                 </tr>
  512. </table>
  513. <font color="red"><span class="template_overage">red = over #cfdebugger.settings.template_highlight_minimum# ms average execution time</span></font>
  514.     </cfoutput>
  515.     <cfcatch type="Any">
  516.     <cfoutput><br>[[cfcatch.message=#cfcatch.message#]]<br></cfoutput>
  517. </cfcatch>
  518.     </cftry>
  519. </cfif> <!--- template_mode = summary--->
  520. <cfelse>
  521. <p class="cfdebug"><hr/><b class="cfdebuglge">Execution Time</b></p>
  522. <a name="cfdebug_templates">
  523. No top level page was found.
  524. </cfif> <!--- if top level templates are available --->
  525. </cfif>
  526. <!--- CFCS --->
  527. <cfquery dbType="query" name="cfcs" debug="false">
  528.     select template, (endTime - startTime) as et, [timestamp]
  529.     from qEvents
  530.     where type = 'Template'
  531.     and template like 'CFC[[ %'
  532.     escape '['
  533.     group by template, [timestamp], startTime, endTime
  534. </cfquery>
  535. <cfset cfcData = structNew()>
  536. <cfloop query="cfcs">
  537.     <cfset tString = replaceNoCase(template, "CFC[ ", "")>
  538.     <cfset tString = reReplace(tString, "] from .*", "")>
  539.     <cfset theCFC = trim(listFirst(tString, "|"))>
  540.     <cfset theMethod = trim(listLast(tString, "|"))>
  541.     <!--- remove args --->
  542.     <cfset theMethod = trim(reReplaceNoCase(theMethod, "\(.*?\).*", "()"))>
  543.     <cfif not structKeyExists(cfcData, theCFC)>
  544.         <cfset cfcData[theCFC] = structNew()>
  545.     </cfif>
  546.     <cfif not structKeyExists(cfcData[theCFC], theMethod)>
  547.         <cfset cfcData[theCFC][theMethod] = structNew()>
  548.         <cfset cfcData[theCFC][theMethod].count = 0>
  549.         <cfset cfcData[theCFC][theMethod].total = 0>
  550.     </cfif>
  551.     <cfset cfcData[theCFC][theMethod].count = cfcData[theCFC][theMethod].count + 1>
  552.     <cfset cfcData[theCFC][theMethod].total = cfcData[theCFC][theMethod].total + et>
  553. </cfloop>
  554. <!--- make averages --->
  555. <cfloop item="cfc" collection="#cfcData#">
  556.     <cfloop item="method" collection="#cfcdata[cfc]#">
  557.         <cfset cfcdata[cfc][method].average = cfcdata[cfc][method].total / cfcdata[cfc][method].count>
  558.     </cfloop>
  559. </cfloop>
  560. <cfoutput>
  561. <p class="cfdebug"><hr/><b class="cfdebuglge">CFC Data</b></p>
  562. <table border="1" cellpadding="2" cellspacing="0" class="cfdebug">
  563.     <tr>
  564.     <td class="cfdebug" align="center"><b>Total Time</b></td>
  565.     <td class=