Skip to content

Commit

Permalink
SuperSize UI: Hide unchanged method nodes in "method count" mode.
Browse files Browse the repository at this point in the history
They were showing up as nodes with count of 0 because their size had
changed but not their count. When in method count mode, it makes more
sense to just hide these nodes.

Bug: 947372
Change-Id: Ic90cf0a41e0cd601687199b7a938a90a786cdab2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611763
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659607}
  • Loading branch information
Andrew Grieve authored and Commit Bot committed May 14, 2019
1 parent bc22292 commit 92c5c79
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions tools/binary_size/libsupersize/static/tree-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ class TreeBuilder {
* attached to the tree.
* @param {(symbolNode: TreeNode) => boolean} options.highlightTest Called to
* see if a symbol should be highlighted.
* @param {boolean} options.methodCountMode Whether we're in "method count"
* mode.
* @param {string} options.sep Path seperator used to find parent names.
* @param {Meta} options.meta Metadata associated with this tree.
*/
constructor(options) {
this._getPath = options.getPath;
this._filterTest = options.filterTest;
this._highlightTest = options.highlightTest;
this._methodCountMode = options.methodCountMode;
this._sep = options.sep || _PATH_SEP;
this._meta = options.meta;

Expand Down Expand Up @@ -416,6 +419,12 @@ class TreeBuilder {
const numAliases =
_KEYS.NUM_ALIASES in symbol ? symbol[_KEYS.NUM_ALIASES] : 1;

// Skip methods that have changed in size but not count when in
// "method count" mode.
if (this._methodCountMode && count === 0) {
continue;
}

const symbolNode = createNode({
// Join file path to symbol name with a ":"
idPath: `${idPath}:${symbol[_KEYS.SYMBOL_NAME]}`,
Expand Down Expand Up @@ -720,7 +729,7 @@ function parseOptions(options) {
highlightTest = () => false;
}

return {groupBy, filterTest, highlightTest, url};
return {groupBy, filterTest, highlightTest, url, methodCountMode};
}

/** @type {TreeBuilder | null} */
Expand All @@ -734,10 +743,12 @@ const fetcher = new DataFetcher('data.ndjson');
* each symbol is tested against
* @param {(symbolNode: TreeNode) => boolean} highlightTest Filter function that
* each symbol's flags are tested against
* @param {boolean} methodCountMode
* @param {(msg: TreeProgress) => void} onProgress
* @returns {Promise<TreeProgress>}
*/
async function buildTree(groupBy, filterTest, highlightTest, onProgress) {
async function buildTree(
groupBy, filterTest, highlightTest, methodCountMode, onProgress) {
/** @type {Meta | null} Object from the first line of the data file */
let meta = null;

Expand Down Expand Up @@ -802,6 +813,7 @@ async function buildTree(groupBy, filterTest, highlightTest, onProgress) {
getPath: getPathMap[groupBy],
filterTest,
highlightTest,
methodCountMode,
sep: groupBy === 'component' ? '>' : _PATH_SEP,
meta,
});
Expand Down Expand Up @@ -835,7 +847,8 @@ async function buildTree(groupBy, filterTest, highlightTest, onProgress) {
const actions = {
/** @param {{input:string|null,options:string}} param0 */
load({input, options}) {
const {groupBy, filterTest, highlightTest, url} = parseOptions(options);
const {groupBy, filterTest, highlightTest, url, methodCountMode} =
parseOptions(options);
if (input === 'from-url://' && url) {
// Display the data from the `load_url` query parameter
console.info('Displaying data from', url);
Expand All @@ -845,10 +858,11 @@ const actions = {
fetcher.setInput(input);
}

return buildTree(groupBy, filterTest, highlightTest, progress => {
// @ts-ignore
self.postMessage(progress);
});
return buildTree(
groupBy, filterTest, highlightTest, methodCountMode, progress => {
// @ts-ignore
self.postMessage(progress);
});
},
/** @param {string} path */
async open(path) {
Expand Down

0 comments on commit 92c5c79

Please sign in to comment.