findslow.cfm
<!---// Set your server log file location here //--->
<cfset filename = "D:\server.log">
<cffile action="read" file="#filename#" variable="buffer">
<cfset fileData = structNew()>
<cfloop index="line" list="#buffer#" delimiters="#chr(10)#">
<cfif findNoCase("second warning limit", line)>
<cfset template = rereplace(line, ".*?processing template: (.*?), completed.*", "\1")>
<cfset time = rereplace(line, ".*?completed in ([0-9,]*?) seconds,.*", "\1")>
<cfset time = replace(time, ",", "", "all")>
<cfif not structKeyExists(fileData, template)>
<cfset fileData[template] = structNew()>
<cfset fileData[template].hitCount = 0>
<cfset fileData[template].total = 0>
<cfset fileData[template].max = 0>
</cfif>
<cfset fileData[template].hitCount = fileData[template].hitCount + 1>
<cfset fileData[template].total = fileData[template].total + time>
<cfif time gt fileData[template].max>
<cfset fileData[template].max = time>
</cfif>
</cfif>
</cfloop>
<cfdocument format="pdf">
<cfoutput><h2>#structCount(fileData)# Total File</h2></cfoutput>
<table width="100%" cellpadding="10" border="1">
<tr>
<th>Template</th>
<th>Times in Log</th>
<th>Avg Execution Time</th>
<th>Max Execution Time</th>
</tr>
<cfloop item="temp" collection="#fileData#">
<cfset average = fileData[temp].total / fileData[temp].hitcount>
<cfif average gt 200>
<cfset style = "color: red">
<cfelse>
<cfset style = "">
</cfif>
<cfoutput>
<tr style="#style#">
<td><b>#temp#</b></td>
<td>#fileData[temp].hitCount#</td>
<td>#numberFormat(average,"9.99")#</td>
<td>#fileData[temp].max#</td>
</tr>
</cfoutput>
</cfloop>
</table>
</cfdocument>
Recent Comments