diff --git a/browser/devtools/performance/modules/logic/frame-utils.js b/browser/devtools/performance/modules/logic/frame-utils.js index 1d05f6cb0123..ef1308390458 100644 --- a/browser/devtools/performance/modules/logic/frame-utils.js +++ b/browser/devtools/performance/modules/logic/frame-utils.js @@ -242,12 +242,11 @@ function getInflatedFrameCache(frameTable) { * @param number index * @param object frameTable * @param object stringTable - * @param object allocationsTable */ -function getOrAddInflatedFrame(cache, index, frameTable, stringTable, allocationsTable) { +function getOrAddInflatedFrame(cache, index, frameTable, stringTable) { let inflatedFrame = cache[index]; if (inflatedFrame === null) { - inflatedFrame = cache[index] = new InflatedFrame(index, frameTable, stringTable, allocationsTable); + inflatedFrame = cache[index] = new InflatedFrame(index, frameTable, stringTable); } return inflatedFrame; }; @@ -258,9 +257,8 @@ function getOrAddInflatedFrame(cache, index, frameTable, stringTable, allocation * @param number index * @param object frameTable * @param object stringTable - * @param object allocationsTable */ -function InflatedFrame(index, frameTable, stringTable, allocationsTable) { +function InflatedFrame(index, frameTable, stringTable) { const LOCATION_SLOT = frameTable.schema.location; const IMPLEMENTATION_SLOT = frameTable.schema.implementation; const OPTIMIZATIONS_SLOT = frameTable.schema.optimizations; @@ -274,7 +272,6 @@ function InflatedFrame(index, frameTable, stringTable, allocationsTable) { this.optimizations = frame[OPTIMIZATIONS_SLOT]; this.line = frame[LINE_SLOT]; this.column = undefined; - this.allocations = allocationsTable ? allocationsTable[index] : 0; this.category = category; this.isContent = false; @@ -505,10 +502,10 @@ function getFrameInfo (node, options) { data.COSTS_CALCULATED = true; } - if (options && options.allocations && !data.ALLOCATIONS_CALCULATED) { - data.totalAllocations = node.allocations + node.calls.reduce((acc, node) => acc + node.allocations, 0); - data.selfAllocations = node.allocations; - data.ALLOCATIONS_CALCULATED = true; + if (options && options.allocations && !data.ALLOCATION_DATA_CALCULATED) { + data.selfCount = node.youngestFrameSamples; + data.totalCount = node.samples; + data.ALLOCATION_DATA_CALCULATED = true; } return data; diff --git a/browser/devtools/performance/modules/logic/tree-model.js b/browser/devtools/performance/modules/logic/tree-model.js index d7438eec5aae..21d32cb5e6a8 100644 --- a/browser/devtools/performance/modules/logic/tree-model.js +++ b/browser/devtools/performance/modules/logic/tree-model.js @@ -37,14 +37,14 @@ function ThreadNode(thread, options = {}) { this.duration = options.endTime - options.startTime; this.nodeType = "Thread"; - let { samples, stackTable, frameTable, stringTable, allocationsTable } = thread; + let { samples, stackTable, frameTable, stringTable } = thread; // Nothing to do if there are no samples. if (samples.data.length === 0) { return; } - this._buildInverted(samples, stackTable, frameTable, stringTable, allocationsTable, options); + this._buildInverted(samples, stackTable, frameTable, stringTable, options); if (!options.invertTree) { this._uninvert(); } @@ -67,9 +67,6 @@ ThreadNode.prototype = { * The table of deduplicated frames from the backend. * @param object stringTable * The table of deduplicated strings from the backend. - * @param object allocationsTable - * The table of allocation counts from the backend. Indexed by frame - * index. * @param object options * Additional supported options * - number startTime @@ -77,7 +74,7 @@ ThreadNode.prototype = { * - boolean contentOnly [optional] * - boolean invertTree [optional] */ - _buildInverted: function buildInverted(samples, stackTable, frameTable, stringTable, allocationsTable, options) { + _buildInverted: function buildInverted(samples, stackTable, frameTable, stringTable, options) { function getOrAddFrameNode(calls, isLeaf, frameKey, inflatedFrame, isMetaCategory, leafTable) { // Insert the inflated frame into the call tree at the current level. let frameNode; @@ -203,7 +200,7 @@ ThreadNode.prototype = { // Inflate the frame. let inflatedFrame = getOrAddInflatedFrame(inflatedFrameCache, frameIndex, frameTable, - stringTable, allocationsTable); + stringTable); // Compute the frame key. mutableFrameKeyOptions.isRoot = stackIndex === null; @@ -382,11 +379,10 @@ ThreadNode.prototype = { * Whether or not this is a platform node that should appear as a * generalized meta category or not. */ -function FrameNode(frameKey, { location, line, category, allocations, isContent }, isMetaCategory) { +function FrameNode(frameKey, { location, line, category, isContent }, isMetaCategory) { this.key = frameKey; this.location = location; this.line = line; - this.allocations = allocations; this.youngestFrameSamples = 0; this.samples = 0; this.calls = []; diff --git a/browser/devtools/performance/modules/widgets/tree-view.js b/browser/devtools/performance/modules/widgets/tree-view.js index b868801f8109..fe9d8045e235 100644 --- a/browser/devtools/performance/modules/widgets/tree-view.js +++ b/browser/devtools/performance/modules/widgets/tree-view.js @@ -37,10 +37,10 @@ const DEFAULT_AUTO_EXPAND_DEPTH = 3; // depth const DEFAULT_VISIBLE_CELLS = { duration: true, percentage: true, - allocations: false, + count: false, selfDuration: true, selfPercentage: true, - selfAllocations: false, + selfCount: false, samples: true, function: true }; @@ -134,30 +134,31 @@ CallView.prototype = Heritage.extend(AbstractTreeItem.prototype, { */ _displaySelf: function(document, arrowNode) { let frameInfo = this.getDisplayedData(); + let cells = []; if (this.visibleCells.duration) { - var durationCell = this._createTimeCell(document, frameInfo.totalDuration); - } - if (this.visibleCells.selfDuration) { - var selfDurationCell = this._createTimeCell(document, frameInfo.selfDuration, true); + cells.push(this._createTimeCell(document, frameInfo.totalDuration)); } if (this.visibleCells.percentage) { - var percentageCell = this._createExecutionCell(document, frameInfo.totalPercentage); + cells.push(this._createExecutionCell(document, frameInfo.totalPercentage)); + } + if (this.visibleCells.count) { + cells.push(this._createCountCell(document, frameInfo.totalCount)); + } + if (this.visibleCells.selfDuration) { + cells.push(this._createTimeCell(document, frameInfo.selfDuration, true)); } if (this.visibleCells.selfPercentage) { - var selfPercentageCell = this._createExecutionCell(document, frameInfo.selfPercentage, true); + cells.push(this._createExecutionCell(document, frameInfo.selfPercentage, true)); } - if (this.visibleCells.allocations) { - var allocationsCell = this._createAllocationsCell(document, frameInfo.totalAllocations); - } - if (this.visibleCells.selfAllocations) { - var selfAllocationsCell = this._createAllocationsCell(document, frameInfo.selfAllocations, true); + if (this.visibleCells.selfCount) { + cells.push(this._createCountCell(document, frameInfo.selfCount, true)); } if (this.visibleCells.samples) { - var samplesCell = this._createSamplesCell(document, frameInfo.samples); + cells.push(this._createSamplesCell(document, frameInfo.samples)); } if (this.visibleCells.function) { - var functionCell = this._createFunctionCell(document, arrowNode, frameInfo.name, frameInfo, this.level); + cells.push(this._createFunctionCell(document, arrowNode, frameInfo.name, frameInfo, this.level)); } let targetNode = document.createElement("hbox"); @@ -169,29 +170,9 @@ CallView.prototype = Heritage.extend(AbstractTreeItem.prototype, { if (this.hidden) { targetNode.style.display = "none"; } - if (this.visibleCells.duration) { - targetNode.appendChild(durationCell); - } - if (this.visibleCells.percentage) { - targetNode.appendChild(percentageCell); - } - if (this.visibleCells.allocations) { - targetNode.appendChild(allocationsCell); - } - if (this.visibleCells.selfDuration) { - targetNode.appendChild(selfDurationCell); - } - if (this.visibleCells.selfPercentage) { - targetNode.appendChild(selfPercentageCell); - } - if (this.visibleCells.selfAllocations) { - targetNode.appendChild(selfAllocationsCell); - } - if (this.visibleCells.samples) { - targetNode.appendChild(samplesCell); - } - if (this.visibleCells.function) { - targetNode.appendChild(functionCell); + + for (let i = 0; i < cells.length; i++) { + targetNode.appendChild(cells[i]); } return targetNode; @@ -239,10 +220,10 @@ CallView.prototype = Heritage.extend(AbstractTreeItem.prototype, { cell.setAttribute("value", L10N.numberWithDecimals(percentage, 2) + PERCENTAGE_UNITS); return cell; }, - _createAllocationsCell: function(doc, count, isSelf = false) { + _createCountCell: function(doc, count, isSelf = false) { let cell = doc.createElement("description"); cell.className = "plain call-tree-cell"; - cell.setAttribute("type", isSelf ? "self-allocations" : "allocations"); + cell.setAttribute("type", isSelf ? "self-count" : "count"); cell.setAttribute("crop", "end"); cell.setAttribute("value", count || 0); return cell; @@ -356,7 +337,7 @@ CallView.prototype = Heritage.extend(AbstractTreeItem.prototype, { return this._cachedDisplayedData = this.frame.getInfo({ root: this.root.frame, - allocations: (this.visibleCells.allocations || this.visibleCells.selfAllocations) + allocations: (this.visibleCells.count || this.visibleCells.selfCount) }); /** diff --git a/browser/devtools/performance/performance.xul b/browser/devtools/performance/performance.xul index 3f0e38d444ee..a01924218cbc 100644 --- a/browser/devtools/performance/performance.xul +++ b/browser/devtools/performance/performance.xul @@ -305,12 +305,12 @@