38 if not path
in parent_map:
39 head = os.path.split(path)[0]
41 parent_map[path] =
"ROOT"
44 parent_map[path] = head
54 parent = parent_map[path]
55 if parent !=
"ROOT": parent =
"%s (Path)" % parent
56 print(
"['%s (Path)', '%s', 0]," % (path, parent))
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],
""")
72 symbol_frequencies = {}
78 for line
in sys.stdin:
79 vals = line.rstrip().split(
"\t")
81 print(
"ERROR: Failed to match line\n" + line)
83 (filepath, symbol, vmsize, filesize) = vals
87 if filepath.startswith(
"[")
or symbol.startswith(
"["):
91 while filepath.startswith(
"../"):
92 filepath = filepath[3:];
95 if filepath.startswith(
"/"):
96 rel_path_start = filepath.find(
"third_party")
97 if rel_path_start >= 0:
98 filepath = filepath[rel_path_start:]
100 print(
"ERROR: Unexpected absolute path:\n" + filepath)
104 symbol = symbol.replace(
"'",
"\\'")
111 if symbol
not in symbol_frequencies:
112 symbol_frequencies[symbol] = 1
114 freq = symbol_frequencies[symbol]
115 symbol_frequencies[symbol] = freq + 1
116 symbol +=
"_" + str(freq)
119 print(
"['%s', '%s (Path)', %d]," % (symbol, filepath,
int(filesize)))
123 tree = new google.visualization.TreeMap(document.getElementById('chart_div'));
125 generateTooltip: showTooltip
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>`;
141 <div id=
"chart_div" style=
"width: 100%; height: 100%;"></div>
145if __name__ == "__main__":
static float next(float f)
def print(*args, **kwargs)