treemapFromJson function
Map<String, dynamic>
treemapFromJson(
- Object inputJson, {
- TreemapFormat format = TreemapFormat.objectType,
- bool collapseSingleChildPathNodes = true,
Convert the given AOT snapshot information file into a treemap object, represented as a Map. Each node of the tree has one of the two schemas.
Leaf symbol nodes:
{
'k': kindSymbol,
'n': /* name */,
'lastPathElement': true,
't': symbolTypeGlobalText | symbolTypeGlobalInitializedData,
'value': /* symbol size */
}
Path nodes:
{
'k': kindPath,
'n': /* name */,
'children': /* array of treemap nodes */
}
If inputJson
represents a V8 snapshot profile then format
allows to
controls how individual v8_profile.Snapshot nodes are collapsed into
leaf treemap nodes (see TreemapFormat for more details).
By default chains of single child path nodes are collapsed into a single
path node, e.g.
{k: 'p', n: 'a', children: [{k: 'p', n: 'b', children: [...]}]}
becomes {k: 'p', n: 'a/b', children: [...]}
. This behavior is controlled
by collapseSingleChildPathNodes
parameter and can be switched off by
setting it to false
.
Implementation
Map<String, dynamic> treemapFromJson(Object inputJson,
{TreemapFormat format = TreemapFormat.objectType,
bool collapseSingleChildPathNodes = true}) {
final root = {'n': '', 'children': {}, 'k': kindPath, 'maxDepth': 0};
if (v8_profile.Snapshot.isV8HeapSnapshot(inputJson)) {
_treemapFromSnapshot(
root, v8_profile.Snapshot.fromJson(inputJson as Map<String, dynamic>),
format: format);
} else {
final symbols = instruction_sizes.fromJson(inputJson as List<dynamic>);
for (var symbol in symbols) {
_addSymbol(root, _treePath(symbol), symbol.name.scrubbed, symbol.size);
}
}
return _flatten(root,
collapseSingleChildPathNodes: collapseSingleChildPathNodes);
}