forked from catchpoint/WebPageTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreakdownTimeline.php
More file actions
327 lines (293 loc) · 14.5 KB
/
Copy pathbreakdownTimeline.php
File metadata and controls
327 lines (293 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
include 'common.inc';
require_once('breakdown.inc');
require_once('contentColors.inc');
require_once('waterfall.inc');
require_once('page_data.inc');
$page_keywords = array('Timeline Breakdown','Webpagetest','Website Speed Test','Page Speed');
$page_description = "Chrome main thread processing breakdown$testLabel";
?>
<!DOCTYPE html>
<html>
<head>
<title>WebPagetest Content Breakdown<?php echo $testLabel; ?></title>
<?php $gaTemplate = 'Content Breakdown'; include ('head.inc'); ?>
<style type="text/css">
td {
text-align:left;
vertical-align:top;
padding:1em;
}
div.bar {
height:12px;
margin-top:auto;
margin-bottom:auto;
}
div.table {
margin-left: auto;
margin-right: auto;
}
td.legend {
white-space:nowrap;
text-align:left;
vertical-align:top;
padding:0;
}
th.header {
font-weight: normal;
}
</style>
</head>
<body>
<div class="page">
<?php
$tab = 'Test Result';
$subtab = 'Processing Breakdown';
include 'header.inc';
$processing = GetDevToolsCPUTime($testPath, $run, $cached);
if (isset($processing)) {
arsort($processing);
$mapping = array('EvaluateScript' => 'Scripting',
'v8.compile' => 'Scripting',
'FunctionCall' => 'Scripting',
'GCEvent' => 'Scripting',
'TimerFire' => 'Scripting',
'EventDispatch' => 'Scripting',
'TimerInstall' => 'Scripting',
'TimerRemove' => 'Scripting',
'XHRLoad' => 'Scripting',
'XHRReadyStateChange' => 'Scripting',
'MinorGC' => 'Scripting',
'MajorGC' => 'Scripting',
'FireAnimationFrame' => 'Scripting',
'ThreadState::completeSweep' => 'Scripting',
'Heap::collectGarbage' => 'Scripting',
'ThreadState::performIdleLazySweep' => 'Scripting',
'Layout' => 'Layout',
'UpdateLayoutTree' => 'Layout',
'RecalculateStyles' => 'Layout',
'ParseAuthorStyleSheet' => 'Layout',
'ScheduleStyleRecalculation' => 'Layout',
'InvalidateLayout' => 'Layout',
'Paint' => 'Painting',
'DecodeImage' => 'Painting',
'Decode Image' => 'Painting',
'ResizeImage' => 'Painting',
'CompositeLayers' => 'Painting',
'Rasterize' => 'Painting',
'PaintImage' => 'Painting',
'PaintSetup' => 'Painting',
'ImageDecodeTask' => 'Painting',
'GPUTask' => 'Painting',
'SetLayerTreeId' => 'Painting',
'layerId' => 'Painting',
'UpdateLayer' => 'Painting',
'UpdateLayerTree' => 'Painting',
'Draw LazyPixelRef' => 'Painting',
'Decode LazyPixelRef' => 'Painting',
'ParseHTML' => 'Loading',
'ResourceReceivedData' => 'Loading',
'ResourceReceiveResponse' => 'Loading',
'ResourceSendRequest' => 'Loading',
'ResourceFinish' => 'Loading',
'CommitLoad' => 'Loading',
'Idle' => 'Idle');
$groups = array('Scripting' => 0, 'Layout' => 0, 'Painting' => 0, 'Loading' => 0, 'Other' => 0, 'Idle' => 0);
$groupColors = array('Scripting' => '#f1c453',
'Layout' => '#9a7ee6',
'Painting' => '#71b363',
'Loading' => '#70a2e3',
'Other' => '#f16161',
'Idle' => '#cbd1d9');
if (!array_key_exists('Idle', $processing))
$processing['Idle'] = 0;
foreach ($processing as $type => $time) {
$group = 'Other';
if (array_key_exists($type, $mapping))
$group = $mapping[$type];
$groups[$group] += $time;
}
}
?>
<table align="center">
<tr>
<th class="header" colspan="2">
<h2>Main thread processing breakdown</h2>
Where the browser's main thread was busy, not including idle time waiting for resources <?php
echo " (<a href=\"/timeline/" . VER_TIMELINE . "timeline.php?test=$id&run=$run&cached=$cached\" title=\"View Chrome Dev Tools Timeline\">view timeline</a>)";
?>.
</th>
</tr>
<tr>
<td>
<div id="pieGroups" style="width:450px; height:300px;"></div>
</td>
<td>
<div id="pieEvents" style="width:450px; height:300px;"></div>
</td>
</tr>
<tr>
<td>
<div class="table" id="tableGroups" style="width: 200px;"></div>
</td>
<td>
<div class="table" id="tableEvents" style="width: 400px;"></div>
</td>
</tr>
<tr>
<th class="header" colspan="2">
<h2>Main thread time breakdown</h2>
All of the main thread activity including idle (waiting for resources usually) <?php
echo " (<a href=\"/timeline/" . VER_TIMELINE . "timeline.php?test=$id&run=$run&cached=$cached\" title=\"View Chrome Dev Tools Timeline\">view timeline</a>)";
?>.
</th>
</tr>
<tr>
<td>
<div id="pieGroupsIdle" style="width:450px; height:300px;"></div>
</td>
<td>
<div id="pieEventsIdle" style="width:450px; height:300px;"></div>
</td>
</tr>
<tr>
<td>
<div class="table" id="tableGroupsIdle" style="width: 200px;"></div>
</td>
<td>
<div class="table" id="tableEventsIdle" style="width: 400px;"></div>
</td>
</tr>
</table>
</div>
<?php include('footer.inc'); ?>
<!--Load the AJAX API-->
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the table package.
google.load('visualization', '1', {'packages':['table', 'corechart']});
google.setOnLoadCallback(drawTable);
function drawTable() {
var groups = new google.visualization.DataTable();
groups.addColumn('string', 'Category');
groups.addColumn('number', 'Time (ms)');
groups.addRows(<?php echo (count($groups) - 1); ?>);
var groupColors = new Array();
var events = new google.visualization.DataTable();
events.addColumn('string', 'Event');
events.addColumn('number', 'Time (ms)');
events.addRows(<?php echo (count($processing) - 1); ?>);
var eventColors = new Array();
<?php
$index = 0;
if (isset($groups) && is_array($groups) && count($groups)) {
foreach($groups as $type => $time)
{
if ($type != 'Idle') {
echo "groups.setValue($index, 0, '$type');\n";
echo "groups.setValue($index, 1, $time);\n";
$color = $groupColors[$type];
echo "groupColors.push('$color');\n";
$index++;
}
}
}
$index = 0;
if (isset($processing) && is_array($processing) && count($processing)) {
foreach($processing as $type => $time) {
if ($type != 'Idle') {
echo "events.setValue($index, 0, '$type');\n";
echo "events.setValue($index, 1, $time);\n";
$group = 'Other';
if (array_key_exists($type, $mapping))
$group = $mapping[$type];
$color = $groupColors[$group];
echo "eventColors.push('$color');\n";
$index++;
}
}
}
?>
var viewGroups = new google.visualization.DataView(groups);
viewGroups.setColumns([0, 1]);
var tableGroups = new google.visualization.Table(document.getElementById('tableGroups'));
tableGroups.draw(viewGroups, {showRowNumber: false, sortColumn: 1, sortAscending: false});
var pieGroups = new google.visualization.PieChart(document.getElementById('pieGroups'));
google.visualization.events.addListener(pieGroups, 'ready', function(){markUserTime('aft.Groups Pie');});
pieGroups.draw(viewGroups, {width: 450, height: 300, title: 'Processing Categories', colors: groupColors});
var viewEvents = new google.visualization.DataView(events);
viewEvents.setColumns([0, 1]);
var tableEvents = new google.visualization.Table(document.getElementById('tableEvents'));
tableEvents.draw(viewEvents, {showRowNumber: false, sortColumn: 1, sortAscending: false});
var pieEvents = new google.visualization.PieChart(document.getElementById('pieEvents'));
google.visualization.events.addListener(pieEvents, 'ready', function(){markUserTime('aft.Events Pie');});
pieEvents.draw(viewEvents, {width: 450, height: 300, title: 'Processing Events', colors: eventColors});
var groupsIdle = new google.visualization.DataTable();
groupsIdle.addColumn('string', 'Category');
groupsIdle.addColumn('number', 'Time (ms)');
groupsIdle.addRows(<?php echo count($groups); ?>);
var groupColors = new Array();
var eventsIdle = new google.visualization.DataTable();
eventsIdle.addColumn('string', 'Event');
eventsIdle.addColumn('number', 'Time (ms)');
eventsIdle.addRows(<?php echo count($processing); ?>);
var eventColors = new Array();
<?php
$index = 0;
if (isset($groups) && is_array($groups) && count($groups)) {
foreach($groups as $type => $time)
{
echo "groupsIdle.setValue($index, 0, '$type');\n";
echo "groupsIdle.setValue($index, 1, $time);\n";
$color = $groupColors[$type];
echo "groupColors.push('$color');\n";
$index++;
}
}
$index = 0;
if (isset($processing) && is_array($processing) && count($processing)) {
foreach($processing as $type => $time)
{
echo "eventsIdle.setValue($index, 0, '$type');\n";
echo "eventsIdle.setValue($index, 1, $time);\n";
$group = 'Other';
if (array_key_exists($type, $mapping))
$group = $mapping[$type];
$color = $groupColors[$group];
echo "eventColors.push('$color');\n";
$index++;
}
}
?>
var viewGroupsIdle = new google.visualization.DataView(groupsIdle);
viewGroupsIdle.setColumns([0, 1]);
var tableGroupsIdle = new google.visualization.Table(document.getElementById('tableGroupsIdle'));
tableGroupsIdle.draw(viewGroupsIdle, {showRowNumber: false, sortColumn: 1, sortAscending: false});
var pieGroupsIdle = new google.visualization.PieChart(document.getElementById('pieGroupsIdle'));
pieGroupsIdle.draw(viewGroupsIdle, {width: 450, height: 300, title: 'Processing Categories', colors: groupColors});
var viewEventsIdle = new google.visualization.DataView(eventsIdle);
viewEventsIdle.setColumns([0, 1]);
var tableEventsIdle = new google.visualization.Table(document.getElementById('tableEventsIdle'));
tableEventsIdle.draw(viewEventsIdle, {showRowNumber: false, sortColumn: 1, sortAscending: false});
var pieEventsIdle = new google.visualization.PieChart(document.getElementById('pieEventsIdle'));
pieEventsIdle.draw(viewEventsIdle, {width: 450, height: 300, title: 'Processing Events', colors: eventColors});
}
</script>
</body>
</html>
<?php
function rgb2html($r, $g=-1, $b=-1)
{
if (is_array($r) && sizeof($r) == 3)
list($r, $g, $b) = $r;
$r = intval($r); $g = intval($g);
$b = intval($b);
$r = dechex($r<0?0:($r>255?255:$r));
$g = dechex($g<0?0:($g>255?255:$g));
$b = dechex($b<0?0:($b>255?255:$b));
$color = (strlen($r) < 2?'0':'').$r;
$color .= (strlen($g) < 2?'0':'').$g;
$color .= (strlen($b) < 2?'0':'').$b;
return '#'.$color;
}
?>