Skip to content

Commit

Permalink
2.0.0.2 Template Usage/Covergae
Browse files Browse the repository at this point in the history
- add alt row colouring
- use a darker font
  • Loading branch information
zspitzer committed Mar 25, 2021
1 parent 8aa6bc3 commit 34fb638
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 10 deletions.
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name":"Lucee Performance Analyzer",
"author":"Zac Spitzer",
"version":"2.0.0.1",
"version":"2.0.0.2",
"bugs":"https://github.com/zspitzer/lucee-performance-analyzer/issues",
"thumbnail": "https://raw.githubusercontent.com/zspitzer/lucee-performance-analyzer/master/build/images/logo.png",
"changelog":"",
Expand Down
4 changes: 2 additions & 2 deletions build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Mar 23 23:14:36 CET 2021
build.number=2
#Thu Mar 25 02:52:53 CET 2021
build.number=3
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions source/cfml/plugins/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,21 @@ table pre {
#innercontent {
margin-top: 10px;
margin-left: 3px;
}

.unused-template, .unused-template TD {
background-color:rgb(223 186 186);
color:black;
}

a {
color:black;
}

.no-wrap {
white-space: nowrap;
}

.alt-row {
background-color: #DFDFDF;
}
2 changes: 1 addition & 1 deletion source/cfml/plugins/logs.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
console.log("#local.log.scope.cgi.request_url#", #serializeJson(local.log.scope.cgi)#);
</script>
</cfif>
<tr>
<tr class="#altRow(local.i)#">
<td><a href="?action=debugging.logs&action2=detail&id=#hash(local.log.id&":"&local.log.startTime)#">#path#</td>
<td data-value=#DateDiff('s', "2000-1-1", local.log.starttime)#>
<cfif DateCompare(local.log.starttime, local.midnight) eq -1>
Expand Down
2 changes: 1 addition & 1 deletion source/cfml/plugins/queries.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</thead>
<tbody>
<cfoutput query="local.q" maxrows=#arguments.req.maxrows#>
<tr>
<tr class="#altRow(local.q.currentRow)#">
#renderTemplateLink(arguments.req, local.q.template)#
<td>#NumberFormat(local.q.line)#</td>
<td>#local.q.name#</td>
Expand Down
2 changes: 1 addition & 1 deletion source/cfml/plugins/scopes.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</thead>
<tbody>
<cfoutput query="local.q" maxrows="#arguments.req.maxrows#">
<tr>
<tr class="#altRow(local.q.currentRow)#">
#renderTemplateLink(arguments.req, local.q.template)#
<td>#NumberFormat(local.q.line)#</td>
<td>#local.q.name#</td>
Expand Down
58 changes: 56 additions & 2 deletions source/cfml/plugins/templates.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
}
QuerySetCell(q, "template", local.tmp[1], q.currentrow)
}
</cfscript>

<cfquery name="local.q" dbtype="query">
Expand All @@ -62,6 +61,26 @@
group by template, _function
order by totalTime desc
</cfquery>

<cfscript>
local.templates = [=]; // ordered struct
if ( len( arguments.req.template ) && ! variables.exactTemplatePath ){
local.files = DirectoryList( path=arguments.req.template, recurse=true, listInfo="query",
filter = function(path){
local.e = listLast( arguments.path, "\/." );
return ( Find("cf",local.e) eq 1 );
}
);
//dump(var=local.files, top=10);
loop query = local.files {
templates[ local.files.directory & server.separator.file & local.files.name ] = {
uses: 0 // count usage
, file: QueryRowData( local.files, local.files.currentrow )
};
}
//dump(var=local.templates, top=10);
}
</cfscript>
<Cfset local.src_rows = local.q.recordcount>

<table class="maintbl checkboxtbl sort-table">
Expand All @@ -82,7 +101,7 @@
</thead>
<tbody>
<cfoutput query="local.q" maxrows=#arguments.req.maxrows#>
<tr>
<tr class="#altRow(local.q.currentRow)#">
#renderTemplateLink(arguments.req, local.q.template)#
<td>#local.q._function#<cfif len(local.q._function)>()</cfif></td>
<td align="right">#NumberFormat(local.q.totalTime/(1000*1000))#</td>
Expand Down Expand Up @@ -115,6 +134,41 @@
</cfif>
</tfoot>
</table>

<cfscript>
loop query="local.q" {
if ( StructKeyExists( local.templates, local.q.template ) ){
local.templates[local.q.template].uses ++;
}
}
</cfscript>


<cfif StructCount( local.templates ) gt 0>
<h3>Template Usage (via current debug logs)</h3>
<table class="maintbl checkboxtbl sort-table">
<thead>
<tr>
<th data-type="text">Template</th>
<th>Uses</th>
<th>Size</th>
<th>Last Modified</th>
</tr>
</thead>
<cfoutput>
<tbody>
<cfloop collection="#local.templates#" key="local.t" value="local.c">
<tr class=<cfif local.c.uses eq 0>"unused-template"</cfif>>
#renderTemplateLink(arguments.req, local.t)#
<td align="right">#NumberFormat(local.c.uses)#</td>
<td align="right">#NumberFormat(local.c.file.size)#</td>
<td class="no-wrap">#LSDateTimeFormat(local.c.file.dateLastModified)#</td>
</tr>
</cfloop>
</tbody>
</cfoutput>
</table>
</cfif>
<cfoutput>
#variables.renderUtils.includeLang()#
#variables.renderUtils.includeJavascript("perf")#
Expand Down
2 changes: 1 addition & 1 deletion source/cfml/plugins/threads.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<tbody>

<cfoutput query="q_threads">
<tr>
<tr class="#altRow(local.q.currentRow)#">
<td>#q_threads.name#</td>
<td>#q_threads.threadState#</td>
<td><pre>#q_threads.stack#</pre></td>
Expand Down
2 changes: 1 addition & 1 deletion source/cfml/plugins/timers.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<cfsavecontent variable="local.body">
<tbody>
<cfoutput query="local.q" maxrows=#arguments.req.maxrows#>
<tr>
<tr class="#altRow(local.q.currentRow)#">
<td>#local.q.label#</td>
#renderTemplateLink(arguments.req, local.q.template)#
<td align="right">#prettyTime(local.q.totalTime*1000*1000)#</td>
Expand Down
6 changes: 6 additions & 0 deletions source/cfml/plugins/toolbar.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
request.subtitle = arguments.title;
}
function altRow(currentrow){
if ( arguments.currentRow mod 2 eq 0 )
return "alt-row";
return "zzz";
}
</cfscript>
<cfif len(arguments.req.template)>
<cfscript>
Expand Down

0 comments on commit 34fb638

Please sign in to comment.