Skip to content

Commit 35ad691

Browse files
author
Robert Jackson
committed
Add ability to group by plugin name...
1 parent 4ac1813 commit 35ad691

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

app/components/slow-node-times.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ export default Ember.Component.extend({
3131

3232
filter: filterForBroccoliNodes,
3333

34-
nodes: computed('data', 'filter', 'pluginNameFilter', function() {
34+
nodes: computed('data', 'filter', 'pluginNameFilter', 'groupByPluginName', function() {
3535
let data = this.get('data');
3636
let filter = this.get('filter');
37+
let groupByPluginName = this.get('groupByPluginName');
3738
if (!data) { return []; }
3839

3940
let nodes = data.nodes;
@@ -42,6 +43,26 @@ export default Ember.Component.extend({
4243
nodes = filter(nodes, this);
4344
}
4445

46+
if (groupByPluginName) {
47+
let pluginNameMap = nodes.reduce((memo, node) => {
48+
let pluginName = node.label.broccoliPluginName;
49+
memo[pluginName] = memo[pluginName] || { count: 0, time: 0 };
50+
memo[pluginName].time += node.stats.time.self;
51+
memo[pluginName].count++;
52+
return memo;
53+
}, {})
54+
55+
nodes = [];
56+
for (let pluginName in pluginNameMap) {
57+
nodes.push({
58+
label: { name: pluginName, broccoliPluginName: pluginNameMap[pluginName].count },
59+
stats: {
60+
time: { self: pluginNameMap[pluginName].time}
61+
}
62+
});
63+
}
64+
}
65+
4566
let addonNodes = nodes
4667
.sort((a, b) => {
4768
return b.stats.time.self - a.stats.time.self;

app/templates/components/slow-node-times.hbs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,29 @@
66

77
{{#if (eq filterType 'broccoli-node')}}
88
{{input value=pluginNameFilter placeholder="Filter by plugin name..."}}
9+
<label>Group by Plugin Name{{input type="checkbox" checked=groupByPluginName}}</label>
910
<button {{action (action (mut pluginNameFilter) '')}}>Clear</button>
1011
{{/if}}
1112

1213

13-
<ul>
14-
{{#each nodes as |node|}}
15-
<li>{{node.label.name}} - {{ns-to-ms node.stats.time.self}}</li>
16-
{{/each}}
17-
</ul>
14+
<table>
15+
<thead>
16+
<tr>
17+
<td>Annotation</td>
18+
<td>Additional Details</td>
19+
<td>Time</td>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
{{#each nodes as |node|}}
24+
<tr>
25+
<td>{{node.label.name}}</td>
26+
<td>{{node.label.broccoliPluginName}}</td>
27+
<td>{{ns-to-ms node.stats.time.self}}</td>
28+
</tr>
29+
{{/each}}
30+
</tbody>
31+
</table>
1832

1933
<div>
2034
Total: {{ns-to-ms totalTime}}

0 commit comments

Comments
 (0)