diff options
-rw-r--r-- | webkit/glue/devtools/js/devtools.css | 22 | ||||
-rw-r--r-- | webkit/glue/devtools/js/heap_profiler_panel.js | 113 | ||||
-rw-r--r-- | webkit/glue/devtools/js/profiler_processor.js | 8 |
3 files changed, 101 insertions, 42 deletions
diff --git a/webkit/glue/devtools/js/devtools.css b/webkit/glue/devtools/js/devtools.css index be00ce4..1fa935f 100644 --- a/webkit/glue/devtools/js/devtools.css +++ b/webkit/glue/devtools/js/devtools.css @@ -94,7 +94,7 @@ body.platform-windows.inactive #toolbar { text-align: right; } -#heap-snapshot-summary { +#heap-snapshot-summary-container { position: absolute; padding-top: 20px; bottom: 0; @@ -116,6 +116,26 @@ body.platform-windows.inactive #toolbar { -webkit-background-clip: padding; } +.heap-snapshot-summary { + display: inline-block; + width: 50%; + min-width: 300px; + position: relative; +} + +.heap-snapshot-summary canvas.summary-graph { + width: 225px; +} + +.heap-snapshot-summary-label { + font-size: 12px; + font-weight: bold; + position: absolute; + top: 1px; + width: 50%; + left: 25%; +} + body.platform-windows .section > .header { border: 1px solid rgb(92, 116, 157); background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(105, 133, 180)), to(rgb(92, 116, 157))); diff --git a/webkit/glue/devtools/js/heap_profiler_panel.js b/webkit/glue/devtools/js/heap_profiler_panel.js index 09d7af9..a1b5183 100644 --- a/webkit/glue/devtools/js/heap_profiler_panel.js +++ b/webkit/glue/devtools/js/heap_profiler_panel.js @@ -40,14 +40,31 @@ WebInspector.HeapSnapshotView = function(parent, profile) this.categories = { code: new WebInspector.ResourceCategory("code", WebInspector.UIString("Code"), "rgb(255,121,0)"), - data: new WebInspector.ResourceCategory("data", WebInspector.UIString("Objects and Data"), "rgb(47,102,236)"), - other: new WebInspector.ResourceCategory("other", WebInspector.UIString("Other"), "rgb(186,186,186)") + data: new WebInspector.ResourceCategory("data", WebInspector.UIString("Objects"), "rgb(47,102,236)") }; - this.summaryBar = new WebInspector.SummaryBar(this.categories); - this.summaryBar.element.id = "heap-snapshot-summary"; - this.summaryBar.calculator = new WebInspector.HeapSummaryCalculator(profile.used); - this.element.appendChild(this.summaryBar.element); + var summaryContainer = document.createElement("div"); + summaryContainer.id = "heap-snapshot-summary-container"; + + this.countsSummaryBar = new WebInspector.SummaryBar(this.categories); + this.countsSummaryBar.element.className = "heap-snapshot-summary"; + this.countsSummaryBar.calculator = new WebInspector.HeapSummaryCountCalculator(); + var countsLabel = document.createElement("div"); + countsLabel.className = "heap-snapshot-summary-label"; + countsLabel.textContent = WebInspector.UIString("Count"); + this.countsSummaryBar.element.appendChild(countsLabel); + summaryContainer.appendChild(this.countsSummaryBar.element); + + this.sizesSummaryBar = new WebInspector.SummaryBar(this.categories); + this.sizesSummaryBar.element.className = "heap-snapshot-summary"; + this.sizesSummaryBar.calculator = new WebInspector.HeapSummarySizeCalculator(); + var sizesLabel = document.createElement("label"); + sizesLabel.className = "heap-snapshot-summary-label"; + sizesLabel.textContent = WebInspector.UIString("Size"); + this.sizesSummaryBar.element.appendChild(sizesLabel); + summaryContainer.appendChild(this.sizesSummaryBar.element); + + this.element.appendChild(summaryContainer); var columns = { "cons": { title: WebInspector.UIString("Constructor"), disclosure: true, sortable: true }, "count": { title: WebInspector.UIString("Count"), width: "54px", sortable: true }, @@ -370,8 +387,11 @@ WebInspector.HeapSnapshotView.prototype = { _updateSummaryGraph: function() { - this.summaryBar.calculator.showAsPercent = this._isShowingAsPercent; - this.summaryBar.update(this.profile.lowlevels); + this.countsSummaryBar.calculator.showAsPercent = this._isShowingAsPercent; + this.countsSummaryBar.update(this.profile.lowlevels); + + this.sizesSummaryBar.calculator.showAsPercent = this._isShowingAsPercent; + this.sizesSummaryBar.update(this.profile.lowlevels); } }; @@ -411,25 +431,29 @@ WebInspector.HeapSnapshotView.SearchHelper = { bytes: /B$/i } -WebInspector.HeapSummaryCalculator = function(total) +WebInspector.HeapSummaryCalculator = function(lowLevelField) { - this.total = total; + this.total = 1; + this.lowLevelField = lowLevelField; } WebInspector.HeapSummaryCalculator.prototype = { computeSummaryValues: function(lowLevels) { - function highFromLow(type) { - if (type == "CODE_TYPE" || type == "SHARED_FUNCTION_INFO_TYPE" || type == "SCRIPT_TYPE") return "code"; - if (type == "STRING_TYPE" || type == "HEAP_NUMBER_TYPE" || type.match(/^JS_/) || type.match(/_ARRAY_TYPE$/)) return "data"; - return "other"; - } - var highLevels = {data: 0, code: 0, other: 0}; + var highLevels = {data: 0, code: 0}; + this.total = 0; for (var item in lowLevels) { - var highItem = highFromLow(item); - highLevels[highItem] += lowLevels[item].size; + var highItem = this._highFromLow(item); + if (highItem) { + var value = lowLevels[item][this.lowLevelField]; + highLevels[highItem] += value; + this.total += value; + } } - return {categoryValues: highLevels}; + var result = {categoryValues: highLevels}; + if (!this.showAsPercent) + result.total = this.total; + return result; }, formatValue: function(value) @@ -437,7 +461,7 @@ WebInspector.HeapSummaryCalculator.prototype = { if (this.showAsPercent) return WebInspector.UIString("%.2f%%", value / this.total * 100.0); else - return Number.bytesToString(value); + return this._valueToString(value); }, get showAsPercent() @@ -451,6 +475,42 @@ WebInspector.HeapSummaryCalculator.prototype = { } } +WebInspector.HeapSummaryCountCalculator = function() +{ + WebInspector.HeapSummaryCalculator.call(this, "count"); +} + +WebInspector.HeapSummaryCountCalculator.prototype = { + _highFromLow: function(type) { + if (type == "CODE_TYPE" || type == "SHARED_FUNCTION_INFO_TYPE" || type == "SCRIPT_TYPE") return "code"; + if (type == "STRING_TYPE" || type == "HEAP_NUMBER_TYPE" || type.match(/^JS_/)) return "data"; + return null; + }, + + _valueToString: function(value) { + return value.toString(); + } +} + +WebInspector.HeapSummaryCountCalculator.prototype.__proto__ = WebInspector.HeapSummaryCalculator.prototype; + +WebInspector.HeapSummarySizeCalculator = function() +{ + WebInspector.HeapSummaryCalculator.call(this, "size"); +} + +WebInspector.HeapSummarySizeCalculator.prototype = { + _highFromLow: function(type) { + if (type == "CODE_TYPE" || type == "SHARED_FUNCTION_INFO_TYPE" || type == "SCRIPT_TYPE") return "code"; + if (type == "STRING_TYPE" || type == "HEAP_NUMBER_TYPE" || type.match(/^JS_/) || type.match(/_ARRAY_TYPE$/)) return "data"; + return null; + }, + + _valueToString: Number.bytesToString +} + +WebInspector.HeapSummarySizeCalculator.prototype.__proto__ = WebInspector.HeapSummaryCalculator.prototype; + WebInspector.HeapSnapshotSidebarTreeElement = function(snapshot) { this.profile = snapshot; @@ -472,19 +532,6 @@ WebInspector.HeapSnapshotSidebarTreeElement.prototype = { { this._mainTitle = x; this.refreshTitles(); - }, - - get subtitle() - { - if (this._subTitle) - return this._subTitle; - return WebInspector.UIString("Used %s of %s (%.0f%%)", Number.bytesToString(this.profile.used, null, false), Number.bytesToString(this.profile.capacity, null, false), this.profile.used / this.profile.capacity * 100.0); - }, - - set subtitle(x) - { - this._subTitle = x; - this.refreshTitles(); } }; diff --git a/webkit/glue/devtools/js/profiler_processor.js b/webkit/glue/devtools/js/profiler_processor.js index 4d1c499..b655229 100644 --- a/webkit/glue/devtools/js/profiler_processor.js +++ b/webkit/glue/devtools/js/profiler_processor.js @@ -455,8 +455,6 @@ devtools.profiler.Processor.prototype.processHeapSampleBegin_ = function( devtools.profiler.Processor.prototype.processHeapSampleStats_ = function( space, state, capacity, used) { if (space != 'Heap') return; - this.currentHeapSnapshot_.capacity = capacity; - this.currentHeapSnapshot_.used = used; }; @@ -519,12 +517,6 @@ devtools.profiler.Processor.prototype.processHeapSampleEnd_ = function( if (space != 'Heap') return; var snapshot = this.currentHeapSnapshot_; this.currentHeapSnapshot_ = null; - // For some reason, 'used' from 'heap-sample-stats' sometimes differ from - // the sum of objects sizes. To avoid discrepancy, we re-calculate 'used'. - snapshot.used = 0; - for (var item in snapshot.lowlevels) { - snapshot.used += snapshot.lowlevels[item].size; - } WebInspector.panels.profiles.addSnapshot(snapshot); }; |