diff options
author | peria@chromium.org <peria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-23 08:23:04 +0000 |
---|---|---|
committer | peria@chromium.org <peria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-23 08:23:04 +0000 |
commit | c3535a615941e02b74a88a8426e27d05e8508963 (patch) | |
tree | 518a963a6bc90995e84f76c5f1f2b317723c47a4 /tools/deep_memory_profiler | |
parent | 97b76425192e404d63d8cc316e85fe52d2a107fc (diff) | |
download | chromium_src-c3535a615941e02b74a88a8426e27d05e8508963.zip chromium_src-c3535a615941e02b74a88a8426e27d05e8508963.tar.gz chromium_src-c3535a615941e02b74a88a8426e27d05e8508963.tar.bz2 |
This CL enables dmprof visualizer to fold open categories in its graph part.
With this CL, when a user closes an open node in the menu tree,
the graph draws the closed category's size as one area.
BUG=259206
Review URL: https://codereview.chromium.org/32413005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/deep_memory_profiler')
-rw-r--r-- | tools/deep_memory_profiler/visualizer/static/menu-view.js | 44 | ||||
-rw-r--r-- | tools/deep_memory_profiler/visualizer/static/profiler.js | 21 |
2 files changed, 45 insertions, 20 deletions
diff --git a/tools/deep_memory_profiler/visualizer/static/menu-view.js b/tools/deep_memory_profiler/visualizer/static/menu-view.js index ff9ec7b..2a88f25 100644 --- a/tools/deep_memory_profiler/visualizer/static/menu-view.js +++ b/tools/deep_memory_profiler/visualizer/static/menu-view.js @@ -48,25 +48,26 @@ MenuView.prototype.redraw_ = function(models) { } } - function merge(left, right) { - if (!('children' in right) && 'children' in left) + function merge(origin, target) { + if (!('children' in origin)) + return; + if (!('children' in target)) { + target.children = origin.children; return; - if ('children' in right && !('children' in left)) - left.children = right.children; - if ('children' in right && 'children' in left) { - right.children.forEach(function(child) { - // Find child with the same label in right tree. - var index = left.children.reduce(function(previous, current, index) { - if (child.label === current.label) - return index; - return previous; - }, -1); - if (index === -1) - left.children.push(child); - else - merge(left.children[index], child); - }); } + + origin.children.forEach(function(child) { + // Find child with the same label in target tree. + var index = target.children.reduce(function(previous, current, index) { + if (child.label === current.label) + return index; + return previous; + }, -1); + if (index === -1) + target.children.push(child); + else + merge(child, target.children[index]); + }); } var self = this; @@ -79,7 +80,7 @@ MenuView.prototype.redraw_ = function(models) { if (!union) union = data; else - merge(union, data); + merge(data, union); }); // Draw breakdown menu. @@ -93,11 +94,16 @@ MenuView.prototype.redraw_ = function(models) { } }); - // Delegate click event to profiler. + // Delegate events this.$tree_.bind('tree.click', function(event) { event.preventDefault(); self.profiler_.setSelected(event.node.id); }); + this.$tree_.bind('tree.close', function(event) { + event.preventDefault(); + self.profiler_.unsetSub(event.node.id); + self.profiler_.setSelected(event.node.id); + }); } else { this.$tree_.tree('loadData', data); } diff --git a/tools/deep_memory_profiler/visualizer/static/profiler.js b/tools/deep_memory_profiler/visualizer/static/profiler.js index e47a4c6..5b8d468 100644 --- a/tools/deep_memory_profiler/visualizer/static/profiler.js +++ b/tools/deep_memory_profiler/visualizer/static/profiler.js @@ -138,7 +138,7 @@ Profiler.prototype.getCurSubById = function(id) { Profiler.prototype.setSub = function(sub) { var selected = this.selected_; var path = selected.split(','); - var key = path[path.length-1]; + var key = path[path.length - 1]; // Add sub breakdown to template. var models = this.getModelsbyId(selected); @@ -151,6 +151,25 @@ Profiler.prototype.setSub = function(sub) { }; /** + * Remove children of figured node and reparse whole tree. + * @param {string} id World-breakdown like 'vm-map'. + */ +Profiler.prototype.unsetSub = function(id) { + var models = this.getModelsbyId(id); + if (!('template' in models[0])) + return; + + var path = id.split(','); + var key = path[path.length - 1]; + if (!(key in models[0].template[2])) + return; + delete (models[0].template[2][key]); + + // Recalculate new template. + this.reparse(); +}; + +/** * Calculate the model of certain snapshot. * @param {string} template Local template. * @param {Object} snapshot Current snapshot. |