Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
Merge branch 'trivial'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ty Overby committed Aug 28, 2014
2 parents 262d370 + b1f8d63 commit 7f8f396
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 26 deletions.
19 changes: 16 additions & 3 deletions web/format_versions/version0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ void processData0(Map document, TreeTable tt) {
'Compile Duration: ' + prog['compile_duration']
].map((t) => new HeadingElement.h3()..text = t));

// Information about specific pieces of the program
tt.columnTitles = ['Kind', 'Name', 'Bytes', '%', 'Type'];

tt.columnInfo(
// Names
['Kind', 'Name', 'Bytes', 'Bytes R', '%', 'Type'],
// Help Info
[
'',
'The given name of the element',
'The direct size attributed to the element',
'The sum of the sizes of all the elements that can '
'only be reached from this element',
'The percentage of the direct size compared to the '
'program size',
'The given type of the element'
],
// Sizes
["200px", null, "100px", "100px", "70px", null]);
// A recursive function that builds up a tree of LogicalRows
LogicalRow buildTree(Map<String, dynamic> node, bool isTop,
HtmlElement tbody, int level) {
Expand Down
36 changes: 28 additions & 8 deletions web/format_versions/version1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ class ViewVersion1 {
}

void display() {
treeTable.columnTitles = ['Kind', 'Name', 'Bytes', '%', 'Type'];
treeTable.columnInfo(
// Names
['Kind', 'Name', 'Bytes', 'Bytes R', '%', 'Type'],
// Help Info
[
'',
'The given name of the element',
'The direct size attributed to the element',
'The sum of the sizes of all the elements that can '
'only be reached from this element',
'The percentage of the direct size compared to the '
'program size',
'The given type of the element'
],
// Sizes
["200px", null, "100px", "100px", "70px", null]);

_setupProgramwideInfo();

Expand Down Expand Up @@ -110,7 +125,8 @@ class ViewVersion1 {
int level, Function fetch) {

// A helper method for generating a row-generating function.
GenerateRowFunction renderSelfWith(Function renderFn, {int sortPriority: 0}) {
GenerateRowFunction renderSelfWith(Function renderFn,
{int sortPriority: 0}) {
void render(TreeTableRow row, LogicalRow lRow) {
row.data = renderFn();
}
Expand All @@ -130,13 +146,13 @@ class ViewVersion1 {
case 'method':
// Side Effects
row.addChild(renderSelfWith(() =>
[_cell('side effects'), _cell(node['sideEffects'], colspan: '4')]));
[_cell('side effects'), _cell(node['sideEffects'], colspan: '5')]));
// Modifiers
if (node.containsKey('modifiers')) {
(node['modifiers'] as Map<String, bool>).forEach((k, v) {
if (v) {
row.addChild(renderSelfWith(() =>
[_cell('modifier'), _cell(k, colspan: '4')]));
[_cell('modifier'), _cell(k, colspan: '5')]));
}
});
}
Expand All @@ -145,7 +161,7 @@ class ViewVersion1 {
[_cell('return type'), _verticalCell(
'inferred: ${node['inferredReturnType']},',
' declared: ${node['returnType']}',
colspan: '4')
colspan: '5')
]));
// Parameters
if (node.containsKey('parameters')) {
Expand All @@ -165,15 +181,15 @@ class ViewVersion1 {
// Code
if (node['code'] != null && node['code'].length != 0) {
row.addChild(renderSelfWith(() =>
[_cell('code'), _cell(node['code'], colspan: '4', pre: true)],
[_cell('code'), _cell(node['code'], colspan: '5', pre: true)],
sortPriority: -1));
}
break;
case 'field':
// Code
if (node['code'] != null && node['code'].length != 0) {
row.addChild(renderSelfWith(() =>
[_cell('code'), _cell(node['code'], colspan: '4', pre: true)],
[_cell('code'), _cell(node['code'], colspan: '5', pre: true)],
sortPriority: -1));
}
// Types
Expand All @@ -183,7 +199,7 @@ class ViewVersion1 {
_verticalCell(
'inferred: ${node['inferredType']}',
'declared: ${node['type']}',
colspan: '4', pre: true)]));
colspan: '5', pre: true)]));
}
break;
case 'class':
Expand Down Expand Up @@ -225,6 +241,7 @@ class ViewVersion1 {
cells.addAll([
new TableCellElement()..children.addAll([span, anchor]),
_cell(props['size'], align: 'right'),
_cell(model.triviallyOwnedSize(props['id']), align: 'right'),
_cell(props['size_percent'], align: 'right'),
_cell(props['type'], pre: true)
]);
Expand All @@ -233,6 +250,7 @@ class ViewVersion1 {
cells.addAll([
_cell(props['name']),
_cell(props['size'], align: 'right'),
_cell(''),
_cell(props['size_percent'], align: 'right'),
_cell('')
]);
Expand All @@ -241,13 +259,15 @@ class ViewVersion1 {
cells.addAll([
_cell(props['name']),
_cell('0', align: 'right'),
_cell('0', align: 'right'),
_cell('0.00%', align:'right')
]);
break;
case 'class':
cells.addAll([
_cell(props['name']),
_cell(props['size'], align: 'right'),
_cell(''),
_cell(props['size_percent'], align:'right'),
_cell(props['name'], pre: true)
]);
Expand Down
29 changes: 29 additions & 0 deletions web/infohelper.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:collection' show Queue;

class Selection {
String elementId;
String mask;
Expand Down Expand Up @@ -116,4 +118,31 @@ class InfoHelper {
traverseNames(node, []);
}
}

bool _parentsAllContained(String id, Set<String> container) =>
reverseDependencies(id).every((a) => container.contains(a.elementId));

Set<String> _triviallyReachedFrom(String id) {
Queue<String> queue = new Queue<String>();
Set<String> owns = new Set<String>();

queue.add(id);
owns.add(id);

while (queue.isNotEmpty) {
String next = queue.removeFirst();
for (String child in dependencies(next).map((a) => a.elementId)) {
if (!owns.contains(child) && _parentsAllContained(child, owns)) {
queue.add(child);
owns.add(child);
}
}
}
return owns;
}

int triviallyOwnedSize(String id) =>
_triviallyReachedFrom(id)
.map((a) => properties(a)['size'])
.reduce((a, b) => a + b);
}
26 changes: 11 additions & 15 deletions web/polymer_lib/tree_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,18 @@ class TreeTable extends PolymerElement {
/**
* Sets the titles for the columns of the table.
*/
void set columnTitles(List<String> names) {
this.$['inner_table_head'].children.addAll(names.map((name) {
var tableCell = new TableCellElement()..text = name;
// TODO(tyoverby): special cases are bad

if (name == 'Bytes' || name == '%') {
tableCell.style.width = '70px';
}
if (name == 'Kind') {
tableCell.style.width = '160px';
void columnInfo(List<String> names, List<String> helps, List<String> sizes) {
for (int i = 0; i < names.length; i ++) {
TableCellElement cell = new TableCellElement();
cell.style.textAlign = 'center';
cell.text = names[i];
cell.title = helps[i];
String size = sizes[i];
if (size != null) {
cell.style.width = size;
}
if (name == 'Name') {
tableCell.style.width = '300px';
}
return tableCell;
}));
this.$['inner_table_head'].children.add(cell);
}
}

/**
Expand Down

0 comments on commit 7f8f396

Please sign in to comment.