From 09fbdf8bc1525cf6c284e230088f23103db232bd Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 31 Jan 2012 12:11:35 +0000 Subject: [PATCH] Web Inspector: show sizes in bytes instead of KB, MB in heap profiler. https://bugs.webkit.org/show_bug.cgi?id=77199 Patch by Alexei Filippov on 2012-01-31 Reviewed by Pavel Feldman. * inspector/front-end/DetailedHeapshotGridNodes.js: (WebInspector.HeapSnapshotGenericObjectNode.prototype.get data): (WebInspector.HeapSnapshotInstanceNode.prototype._enhanceData): (WebInspector.HeapSnapshotConstructorNode.prototype.get data): (WebInspector.HeapSnapshotDiffNode.prototype.get data): * inspector/front-end/UIUtils.js: (Number.withThousandsSeparator): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106354 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 15 +++++++++++++++ .../inspector/front-end/DetailedHeapshotGridNodes.js | 18 +++++++++--------- Source/WebCore/inspector/front-end/UIUtils.js | 9 +++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index fb3eb0c..d2a84cb 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,18 @@ +2012-01-31 Alexei Filippov + + Web Inspector: show sizes in bytes instead of KB, MB in heap profiler. + https://bugs.webkit.org/show_bug.cgi?id=77199 + + Reviewed by Pavel Feldman. + + * inspector/front-end/DetailedHeapshotGridNodes.js: + (WebInspector.HeapSnapshotGenericObjectNode.prototype.get data): + (WebInspector.HeapSnapshotInstanceNode.prototype._enhanceData): + (WebInspector.HeapSnapshotConstructorNode.prototype.get data): + (WebInspector.HeapSnapshotDiffNode.prototype.get data): + * inspector/front-end/UIUtils.js: + (Number.withThousandsSeparator): + 2012-01-26 Hans Wennborg Speech Input: move MockSpeechInputClient into Chromium DumpRenderTree implementation diff --git a/Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js b/Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js index 36e51b0..5bbcd90 100644 --- a/Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js +++ b/Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js @@ -268,8 +268,8 @@ WebInspector.HeapSnapshotGenericObjectNode.prototype = { data["object"] = { valueStyle: valueStyle, value: value + ": @" + this.snapshotNodeId }; var view = this.dataGrid.snapshotView; - data["shallowSize"] = view.showShallowSizeAsPercent ? WebInspector.UIString("%.2f%%", this._shallowSizePercent) : Number.bytesToString(this._shallowSize); - data["retainedSize"] = view.showRetainedSizeAsPercent ? WebInspector.UIString("%.2f%%", this._retainedSizePercent) : Number.bytesToString(this._retainedSize); + data["shallowSize"] = view.showShallowSizeAsPercent ? WebInspector.UIString("%.2f%%", this._shallowSizePercent) : Number.withThousandsSeparator(this._shallowSize); + data["retainedSize"] = view.showRetainedSizeAsPercent ? WebInspector.UIString("%.2f%%", this._retainedSizePercent) : Number.withThousandsSeparator(this._retainedSize); return this._enhanceData ? this._enhanceData(data) : data; }, @@ -503,10 +503,10 @@ WebInspector.HeapSnapshotInstanceNode.prototype = { data["addedCount"] = ""; data["addedSize"] = ""; data["removedCount"] = "\u2022"; - data["removedSize"] = Number.bytesToString(this._shallowSize); + data["removedSize"] = Number.withThousandsSeparator(this._shallowSize); } else { data["addedCount"] = "\u2022"; - data["addedSize"] = Number.bytesToString(this._shallowSize); + data["addedSize"] = Number.withThousandsSeparator(this._shallowSize); data["removedCount"] = ""; data["removedSize"] = ""; } @@ -570,8 +570,8 @@ WebInspector.HeapSnapshotConstructorNode.prototype = { var data = {object: this._name, count: this._count}; var view = this.dataGrid.snapshotView; data["count"] = view.showCountAsPercent ? WebInspector.UIString("%.2f%%", this._countPercent) : this._count; - data["shallowSize"] = view.showShallowSizeAsPercent ? WebInspector.UIString("%.2f%%", this._shallowSizePercent) : Number.bytesToString(this._shallowSize); - data["retainedSize"] = "> " + (view.showRetainedSizeAsPercent ? WebInspector.UIString("%.2f%%", this._retainedSizePercent) : Number.bytesToString(this._retainedSize)); + data["shallowSize"] = view.showShallowSizeAsPercent ? WebInspector.UIString("%.2f%%", this._shallowSizePercent) : Number.withThousandsSeparator(this._shallowSize); + data["retainedSize"] = view.showRetainedSizeAsPercent ? "~" + WebInspector.UIString("%.2f%%", this._retainedSizePercent) : Number.withThousandsSeparator(this._retainedSize) + "+"; return data; }, @@ -751,9 +751,9 @@ WebInspector.HeapSnapshotDiffNode.prototype = { data["addedCount"] = this._addedCount; data["removedCount"] = this._removedCount; data["countDelta"] = WebInspector.UIString("%s%d", this._signForDelta(this._countDelta), Math.abs(this._countDelta)); - data["addedSize"] = Number.bytesToString(this._addedSize); - data["removedSize"] = Number.bytesToString(this._removedSize); - data["sizeDelta"] = WebInspector.UIString("%s%s", this._signForDelta(this._sizeDelta), Number.bytesToString(Math.abs(this._sizeDelta))); + data["addedSize"] = Number.withThousandsSeparator(this._addedSize); + data["removedSize"] = Number.withThousandsSeparator(this._removedSize); + data["sizeDelta"] = WebInspector.UIString("%s%s", this._signForDelta(this._sizeDelta), Number.withThousandsSeparator(Math.abs(this._sizeDelta))); return data; } diff --git a/Source/WebCore/inspector/front-end/UIUtils.js b/Source/WebCore/inspector/front-end/UIUtils.js index ae300ed..e62535d 100644 --- a/Source/WebCore/inspector/front-end/UIUtils.js +++ b/Source/WebCore/inspector/front-end/UIUtils.js @@ -442,6 +442,15 @@ Number.bytesToString = function(bytes, higherResolution) return WebInspector.UIString("%.0fMB", megabytes); } +Number.withThousandsSeparator = function(num) +{ + var str = num + ""; + var re = /(\d+)(\d{3})/; + while (str.match(re)) + str = str.replace(re, "$1,$2"); + return str; +} + WebInspector._missingLocalizedStrings = {}; /** -- 2.7.4