diff options
author | peria@chromium.org <peria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-14 19:07:34 +0000 |
---|---|---|
committer | peria@chromium.org <peria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-14 19:07:34 +0000 |
commit | 42187b92ce4d6537c68cd138023d510020da52fc (patch) | |
tree | 6c3cd0beb017537e52f97add0f36e59b32b71dbb /tools/deep_memory_profiler | |
parent | 955dedb61f08bf519a1a6c65d1aea178586fdf25 (diff) | |
download | chromium_src-42187b92ce4d6537c68cd138023d510020da52fc.zip chromium_src-42187b92ce4d6537c68cd138023d510020da52fc.tar.gz chromium_src-42187b92ce4d6537c68cd138023d510020da52fc.tar.bz2 |
Change the order of stacked categories in the graph of DMP visualizer.
Leaf categories are shown in the order as they show up in the category tree in the menu view.
BUG=305097
TEST=Manual
Review URL: https://codereview.chromium.org/26793003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228501 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/deep_memory_profiler')
-rw-r--r-- | tools/deep_memory_profiler/visualizer/static/graph-view.js | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/tools/deep_memory_profiler/visualizer/static/graph-view.js b/tools/deep_memory_profiler/visualizer/static/graph-view.js index cd20511..d961073 100644 --- a/tools/deep_memory_profiler/visualizer/static/graph-view.js +++ b/tools/deep_memory_profiler/visualizer/static/graph-view.js @@ -21,47 +21,53 @@ var GraphView = function(profiler) { * @private */ GraphView.prototype.generateLines_ = function(models) { - function getLeaves(node, categories) { + function mergeCategoryTree(snapNode, index, n, treeNode, lines) { + if ('children' in snapNode) { + // If |snapNode| is not a leaf node, we should go deeper. + if (!('children' in treeNode)) + treeNode.children = {}; + snapNode.children.forEach(function(child) { + if (!(child.id in treeNode.children)) + treeNode.children[child.id] = {}; + mergeCategoryTree(child, index, n, treeNode.children[child.id], lines); + }); + } else { + // If |snapNode| is a leaf node, register its value. + var id = snapNode.id; + if (!(id in lines)) { + // Allocate an array for a new graph line. + treeNode.name = snapNode.name; + lines[id] = []; + for (var i = 0; i < n; ++i) + lines[id].push([i, 0]); + } + lines[id][index] = [index, snapNode.size]; + } + } + + function getCategoriesMap(node, id, categories) { if ('children' in node) { - node.children.forEach(function(child) { - getLeaves(child, categories); + Object.keys(node.children).forEach(function(id) { + getCategoriesMap(node.children[id], id, categories); }); } else { - categories.push(node); + categories[id] = node.name; } } var lines = {}; + var categoryTree = {}; var categoryMap = {}; var snapshotNum = models.length; - // Initialize lines with all zero. - models.forEach(function(model) { - var categories = []; - getLeaves(model, categories); - categories.forEach(function(category) { - var id = category.id; - if (lines[id]) - return; - lines[id] = []; - for (var i = 0; i < snapshotNum; ++i) - lines[id].push([i, 0]); - categoryMap[id] = category; - }); - }); - - // Assignment lines with values of models. + // Enumerate all existing categories in tree format, with getting values. models.forEach(function(model, index) { - var categories = []; - getLeaves(model, categories); - categories.forEach(function(category) { - var id = category.id; - var size = category.size; - lines[id][index] = [index, size]; - }); + mergeCategoryTree(model, index, snapshotNum, categoryTree, lines); }); + // Convert layout of categories from tree style to hash map style. + getCategoriesMap(categoryTree, '', categoryMap); - return Object.keys(lines).map(function(id) { - var name = categoryMap[id].name; + return Object.keys(categoryMap).map(function(id) { + var name = categoryMap[id]; return { id: id, label: name, |