59
61 <html>
62 <head>
63 <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
64 <script type="text/javascript">
65 google.charts.load('current', {'packages':['treemap']});
66 google.charts.setOnLoadCallback(drawChart);
67 function drawChart() {
68 const data = google.visualization.arrayToDataTable([
69 ['Name', 'Parent', 'Size'],
70 ['ROOT', null, 0],""")
71
72 symbol_frequencies = {}
73
74
75
77
78 for line in sys.stdin:
79 vals = line.rstrip().split("\t")
81 print(
"ERROR: Failed to match line\n" + line)
82 sys.exit(1)
83 (filepath, symbol, vmsize, filesize) = vals
84
85
86
87 if filepath.startswith("[") or symbol.startswith("["):
88 continue
89
90
91 while filepath.startswith("../"):
92 filepath = filepath[3:];
93
94
95 if filepath.startswith("/"):
96 rel_path_start = filepath.find("third_party")
97 if rel_path_start >= 0:
98 filepath = filepath[rel_path_start:]
99 else:
100 print(
"ERROR: Unexpected absolute path:\n" + filepath)
101 sys.exit(1)
102
103
104 symbol = symbol.replace("'", "\\'")
105
106
108
109
110
111 if symbol not in symbol_frequencies:
112 symbol_frequencies[symbol] = 1
113 else:
114 freq = symbol_frequencies[symbol]
115 symbol_frequencies[symbol] = freq + 1
116 symbol += "_" + str(freq)
117
118
119 print(
"['%s', '%s (Path)', %d]," % (symbol, filepath,
int(filesize)))
120
121
123 tree = new google.visualization.TreeMap(document.getElementById('chart_div'));
124 tree.draw(data, {
125 generateTooltip: showTooltip
126 });
127
128 function showTooltip(row, size, value) {
129 const escapedLabel = data.getValue(row, 0)
130 .replace('&', '&')
131 .replace('<', '<')
132 .replace('>', '>')
133 return `<div style="background:#fd9; padding:10px; border-style:solid">
134 <span style="font-family:Courier"> ${escapedLabel} <br>
135 Size: ${size} </div>`;
136 }
137 }
138 </script>
139 </head>
140 <body>
141 <div id="chart_div" style="width: 100%; height: 100%;"></div>
142 </body>
143 </html>""")
144
static float next(float f)