Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit afc576f

Browse files
committed
feat(perf): Add # of specific watchers & avg watcher time to perf pane
The list of watchers in the performance pane now shows: - Total time a particular watcher took in the last digest cycle - The text of the watcher - How many watchers of that type there are - Avg time (total / how many) closes #49
1 parent 0ba5f25 commit afc576f

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

panel/app.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ li .status:empty {
345345
text-overflow: ellipsis;
346346
}
347347

348+
.perf .watcher-table {
349+
width: 100%;
350+
text-align: center;
351+
}
352+
353+
.perf .watcher-table thead {
354+
text-decoration: underline;;
355+
font-size: 1.2em;
356+
}
357+
348358
/* for the canvas */
349359
.graph {
350360
background: black;

panel/perf/perf.html

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,26 @@ <h3 ng-hide="::lastDigestTime">Waiting for first digest cycle...</h3>
2020
</div>
2121
</div>
2222
<hr>
23-
<h3>Digest timings</h3>
24-
<div ng-repeat="watcher in watchTimings">
25-
<pre class="left">{{ watcher.text }}</pre>
26-
<pre class="right">{{ watcher.time | number }} ms</pre>
27-
</div>
23+
<h2>Digest timings</h2>
24+
<table class="watcher-table">
25+
<thead>
26+
<tr>
27+
<td>Watcher text</td>
28+
<td>Watcher total time</td>
29+
<td>Number of Watchers</td>
30+
<td>Average watcher time</td>
31+
</tr>
32+
</thead>
33+
<tbody>
34+
<tr ng-repeat="watcher in watchTimings">
35+
<td><pre>{{ watcher.text }}</pre></td>
36+
<td><pre>{{ watcher.time | number }} ms</pre></td>
37+
<td><pre>{{ watcher.count }}</pre></td>
38+
<td><pre>{{ watcher.time / watcher.count | number }} ms</pre></td>
39+
</tr>
40+
</tbody>
41+
</table>
2842
<hr>
29-
<h3>Raw data</h3>
43+
<h2>Raw data</h2>
3044
<pre>{{ perf | json }}</pre>
3145
</div>

panel/perf/perf.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
'use strict';
22

3-
/* globals angular,document,console */
3+
/* globals angular,document */
44

55
// Awesome canvas graph built with help from Kent Dodds
66
// https://github.com/kentcdodds/ng-stats
77
// Stats generated by eep.js
88
// https://github.com/darach/eep-js
99

1010
angular.module('batarang.app.perf', [])
11-
.controller('PerfController', ['$scope', 'inspectedApp', '$timeout', '$window', PerfController]);
11+
.controller('PerfController', ['$scope', '$timeout', '$window', PerfController]);
1212

13-
function PerfController($scope, inspectedApp, $timeout, $window) {
13+
function PerfController($scope, $timeout, $window) {
1414

1515
$scope.watchTimings = [];
1616
$scope.numWatchers = 0;
@@ -57,19 +57,24 @@ function PerfController($scope, inspectedApp, $timeout, $window) {
5757

5858
var reducedWatches = digestData.events.reduce(function (prev, next) {
5959
if (!prev[next.watch]) {
60-
prev[next.watch] = next.time;
60+
prev[next.watch] = {
61+
time: next.time,
62+
count: 1
63+
};
6164
} else {
62-
prev[next.watch] += next.time;
65+
prev[next.watch].time += next.time;
66+
prev[next.watch].count++;
6367
}
6468
return prev;
6569
}, {});
6670

6771
$scope.watchTimings = Object.keys(reducedWatches)
68-
.filter(function (key) { return reducedWatches[key]; })
72+
.filter(function (key) { return reducedWatches[key].time; })
6973
.map(function (key) {
7074
return {
7175
text: key.trim().replace(/\s{2,}/g, ' '),
72-
time: reducedWatches[key]
76+
time: reducedWatches[key].time,
77+
count: reducedWatches[key].count
7378
};
7479
})
7580
.sort(function (a, b) {

0 commit comments

Comments
 (0)