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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Chrome #include Analysis</title>
<!--Generated by analyze_includes.py. Provides the 'data' object.-->
<script src="include-analysis.js"></script>
<style>
tr td { text-align: right; }
tr td:nth-child(1) { text-align: left; }
tr td:nth-child(2) { text-align: left; }
table#edges tr td:nth-child(3) { text-align: left; }
tbody tr:hover { background-color: #dddddd; }
th { position: sticky; top: 0; background-color: #ffffff }
table#files th:nth-child(n+2) { cursor: pointer; }
th.highlighted { background-color: #dddddd }
th.reversed::after { content: " \2303"; }
#filterResults, #edgeFilterResults { font-weight: bold }
</style>
</head>
<body>
<h1>Chrome #include Analysis (go/chrome-includes) Beta</h1>
<p>Build target: <span id="buildTarget">x</span> (Linux). Revision: <span id="buildRevision">x</span>. Analyzed on: <span id="analysisDate">x</span>.</p>
<p>Number of translation units: <span id="numRoots">x</span>. Total build size (sum of expanded translation unit sizes): <span id="totBuildSize">x</span> bytes.</p>
<p>Number of files: <span id="numFiles">x</span>. Total file size: <span id="totFileSize">x</span> bytes.</p>
<p><a href="https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes-index.html">Archive</a></p>
<button onClick="changeState({view: 'files'})">Per-File Analysis</button>
<button onClick="changeState({view: 'edges'})">Per-Edge Analysis</button>
<label for="limit">Display limit: </label>
<input type="number" id="limit" name="limit" onchange="changeState({limit: event.target.value})">
<hr>
<div id="filesview">
<h2>Per-File Analysis</h2>
<p>
<label for="filter">Filter: (regex)</label>
<input type="text" id="filter" name="filter" size="60">
<button onClick="changeState({filter: document.getElementById('filter').value})" id="apply">Apply</button>
<button onClick="changeState({filter: ''})">Clear</button>
<span id="filterResults"></span>
</p>
<table border="1" id="files">
<thead>
<tr>
<th>#</th>
<th id="filename" onclick="changeState({sort: 'filename'})">Filename</th>
<th id="isize" colspan="2" onclick="changeState({sort: 'isize'})" title="The size of the individual file. Also shown as percentage of the total file size.">Individual Size (B) ⓘ</th>
<th id="tsize" colspan="2" onclick="changeState({sort: 'tsize'})" title="The size of the file and all the files it includes, directly and indirectly. Also shown as percentage of the total build size.">Expanded Size (B) ⓘ</th>
<th id="asize" colspan="2" onclick="changeState({sort: 'asize'})" title="The size added by this file being part of the build. In other words, if this file were empty and had no includes, how much smaller would the build be. Also shown as percentage of the total build size.">Added Size (B) ⓘ</th>
<th id="prevalence" colspan="2" onclick="changeState({sort: 'prevalence'})" title="Number of translation units that this file is part of. Also shown as percentage of the number of translation units.">Occurrences ⓘ</th>
<th id="includedby" onclick="changeState({sort: 'includedby'})" title="In how many files this file is included directly. Click the number to see the files.">Directly Included In ⓘ</th>
<th id="includes" onclick="changeState({sort: 'includes'})" title="How many files this file includes directly. Click the number to see the files.">Direct Includes ⓘ</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div id="edgesview" style="display: none">
<h2>Per-Edge Analysis</h2>
<p>
<label for="includerFilter">Includer (regex):</label>
<input type="text" id="includerFilter" name="includerFilter" size="60">
<label for="includedFilter">Included (regex):</label>
<input type="text" id="includedFilter" name="includedFilter" size="60">
<button onClick="changeState({includer: document.getElementById('includerFilter').value, included: document.getElementById('includedFilter').value})" id="applyEdgeFilter">Apply Filter</button>
<button onClick="changeState({includer: '', included: ''})">Clear</button>
<span id="edgeFilterResults"></span>
</p>
<table border="1" id="edges">
<thead>
<tr>
<th>#</th>
<th>Includer</th>
<th>Included</th>
<th colspan="2" title="The size added by this include edge being part of the build. In other words, if this include edge didn't exist, how much smaller would the build be. Also shown as percentage of the total build size.">Added Size (B) ⓘ</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<hr>
<p>File size does not correlate perfectly with compile time, but can serve as a rough guide to what files are slow to compile.</p>
<p>Analysis by <a href="https://source.chromium.org/chromium/chromium/src/+/HEAD:tools/clang/scripts/analyze_includes.py">analyze_includes.py</a>.</p>
<script>
"use strict";
document.getElementById('filter').addEventListener('keyup', function(event) {
if (event.keyCode == 13) {
document.getElementById('apply').click();
}
});
document.getElementById('includerFilter').addEventListener('keyup', function(event) {
if (event.keyCode == 13) {
document.getElementById('applyEdgeFilter').click();
}
});
document.getElementById('includedFilter').addEventListener('keyup', function(event) {
if (event.keyCode == 13) {
document.getElementById('applyEdgeFilter').click();
}
});
function sum(arr) {
return arr.reduce((a, b) => a + b, 0);
}
const numberFormat = new Intl.NumberFormat('en-US');
function fmt(num) {
return numberFormat.format(num);
}
function regexEscape(str) {
str = str.replaceAll('+', '\\+');
str = str.replaceAll('.', '\\.');
return str;
}
const totFileSize = sum(data.sizes);
const totBuildSize = sum(data.roots.map(r => data.tsizes[r]));
const numRoots = data.roots.length;
document.getElementById('buildTarget').textContent = data.target;
document.getElementById('buildRevision').innerHTML =
`<a href="https://chromium.googlesource.com/chromium/src/+/${data.revision}">${data.revision}</a>`;
document.getElementById('analysisDate').textContent = data.date;
document.getElementById('numRoots').textContent = fmt(numRoots);
document.getElementById('totBuildSize').textContent = fmt(totBuildSize);
document.getElementById('numFiles').textContent = fmt(data.files.length);
document.getElementById('totFileSize').textContent = fmt(totFileSize);
function updateView() {
let s = getState();
document.getElementById('filesview').style = 'display: none';
document.getElementById('edgesview').style = 'display: none';
if (s.get('view') == 'files') {
document.getElementById('filesview').style = 'display: block';
buildFilesTable();
}
if (s.get('view') == 'edges') {
document.getElementById('edgesview').style = 'display: block';
buildEdgesTable();
}
document.getElementById('limit').value = s.get('limit')
}
function intersect(arr1, arr2) {
let s2 = new Set(arr2);
return arr1.filter(x => s2.has(x));
}
function buildFilesTable() {
let fileNums = [...Array(data.files.length).keys()];
const state = getState();
const filter = state.get('filter');
document.getElementById('filter').value = filter;
if (filter !== '') {
const re = new RegExp(filter);
fileNums = fileNums.filter(i => data.files[i].match(re));
document.getElementById('filterResults').innerHTML =
`${fmt(fileNums.length)} result${fileNums.length == 1 ? '' : 's'}.`;
} else {
document.getElementById('filterResults').innerHTML = '';
}
const sortFuncs = {
filename: (i, j) => data.files[i].localeCompare(data.files[j]),
isize: (i, j) => data.sizes[j] - data.sizes[i],
tsize: (i, j) => data.tsizes[j] - data.tsizes[i],
prevalence: (i, j) => data.prevalence[j] - data.prevalence[i],
includedby: (i, j) => data.included_by[j].length - data.included_by[i].length,
includes: (i, j) => data.includes[j].length - data.includes[i].length,
asize: (i, j) => data.asizes[j] - data.asizes[i],
};
document.querySelectorAll('th').forEach(th => th.classList.remove('highlighted', 'reversed'));
document.getElementById(state.get('sort')).classList.add('highlighted', ...(state.get('reverse') ? ['reversed'] : []));
fileNums.sort(sortFuncs[state.get('sort')]);
if (state.get('reverse')) {
fileNums.reverse();
}
const limit = Math.min(parseInt(state.get('limit')), fileNums.length);
fileNums = fileNums.slice(0, limit);
function buildRow(i, rank) {
return `
<tr>
<td>${rank + 1}</td>
<td>
<a href="#${changedStateHash({filter: '^' + regexEscape(data.files[i] + '$')})}">${data.files[i]}</a>
[<a href="https://source.chromium.org/chromium/chromium/src/+/HEAD:${data.files[i]}">cs</a>]
</td>
<td>${fmt(data.sizes[i])}</td> <td>${(100 * data.sizes[i] / totFileSize).toFixed(2)} %</td>
<td>${fmt(data.tsizes[i])}</td> <td>${(100 * data.tsizes[i] / totBuildSize).toFixed(2)} %</td>
<td>${fmt(data.asizes[i])}</td> <td>${(100 * data.asizes[i] / totBuildSize).toFixed(2)} %</td>
<td>${fmt(data.prevalence[i])}</td> <td>${(100 * data.prevalence[i] / numRoots).toFixed(2)} %</td>
<td><a href="#${changedStateHash({view: 'edges', includer: '', included: '^' + regexEscape(data.files[i]) + '$'})}">${fmt(data.included_by[i].length)}</a></td>
<td><a href="#${changedStateHash({view: 'edges', included: '', includer: '^' + regexEscape(data.files[i]) + '$'})}">${fmt(data.includes[i].length)}</a></td>
</tr>
`;
}
const tbody = document.querySelector('table#files tbody');
tbody.innerHTML = fileNums.map(buildRow).join('');
}
function buildEdgesTable() {
const state = getState();
const includerFilter = state.get('includer');
const includedFilter = state.get('included');
document.getElementById('includerFilter').value = includerFilter;
document.getElementById('includedFilter').value = includedFilter;
const includerRe = new RegExp(includerFilter);
const includedRe = new RegExp(includedFilter);
let edgeSizes = [];
for (let src = 0; src < data.esizes.length; src++) {
for (let dst = 0; dst < data.esizes[src].length; dst++) {
const includer = src;
const included = data.includes[src][dst];
const esize = data.esizes[src][dst];
if (!data.files[includer].match(includerRe))
continue;
if (!data.files[included].match(includedRe))
continue;
edgeSizes.push([src, data.includes[src][dst], data.esizes[src][dst]]);
}
}
if (includerFilter == '' && includedFilter == '') {
document.getElementById('edgeFilterResults').innerHTML = '';
} else {
document.getElementById('edgeFilterResults').innerHTML =
`${fmt(edgeSizes.length)} result${edgeSizes.length == 1 ? '' : 's'}.`;
}
function buildRow(edgeNum) {
const src = edgeSizes[edgeNum][0];
const dst = edgeSizes[edgeNum][1];
const size = edgeSizes[edgeNum][2];
return `
<tr>
<td>${edgeNum + 1}</td>
<td>
<a href="#${changedStateHash({view: 'files', filter: '^' + regexEscape(data.files[src]) + '$'})}">${data.files[src]}</a>
[<a href="https://source.chromium.org/chromium/chromium/src/+/HEAD:${data.files[src]}">cs</a>]
</td>
<td>
<a href="#${changedStateHash({view: 'files', filter: '^' + regexEscape(data.files[dst]) + '$'})}">${data.files[dst]}</a>
[<a href="https://source.chromium.org/chromium/chromium/src/+/HEAD:${data.files[dst]}">cs</a>]
</td>
<td>${fmt(size)}</td> <td>${(100 * size / totBuildSize).toFixed(2)} %</td>
</tr>
`;
}
edgeSizes.sort((x, y) => y[2] - x[2]);
const limit = Math.min(parseInt(state.get('limit')), edgeSizes.length);
const edgeNums = [...Array(limit).keys()];
const tbody = document.querySelector('table#edges tbody');
tbody.innerHTML = edgeNums.map(buildRow).join('');
document.querySelector('table#edges').appendChild(tbody);
}
function getState() {
let params = new URLSearchParams(window.location.hash.substring(1));
if (!params.has('view'))
params.set('view', 'files');
if (!params.has('filter'))
params.set('filter', '');
if (!params.has('sort'))
params.set('sort', 'asize');
if (!params.has('reverse'))
params.set('reverse', '');
if (!params.has('includer'))
params.set('includer', '');
if (!params.has('included'))
params.set('included', '');
if (!params.has('limit'))
params.set('limit', '1000');
return params;
}
function changedStateHash(changes) {
let s = getState();
for (const [key, value] of Object.entries(changes)) {
if (key === 'sort') {
if (value === s.get('sort')) {
s.set('reverse', s.get('reverse') ? '' : '1');
continue;
} else {
s.set('reverse', '');
}
}
s.set(key, value);
}
return s.toString();
}
function changeState(changes) {
window.location.hash = changedStateHash(changes);
}
window.onhashchange = updateView;
updateView();
</script>
</body>
</html>
|