From ea3b3b9887949307ec1b74cf91a804459f6685cf Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 7 Jul 2011 16:37:26 +1000 Subject: [PATCH] Bug 668893 - Sort about:memory items of type COUNT alphabetically. r=jlebar. --- .../aboutmemory/content/aboutMemory.js | 19 +++++++++++++------ .../tests/chrome/test_aboutmemory.xul | 4 ++-- .../telemetry/TelemetryHistograms.h | 2 +- toolkit/components/telemetry/TelemetryPing.js | 2 +- xpcom/base/nsMemoryReporterManager.cpp | 12 ++++++------ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 1d5cd36e69c..51dce2f029a 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -248,15 +248,22 @@ function update() content.appendChild(div); } -// Compare two memory reporter nodes. We want to group together measurements -// with the same units, so sort first by the nodes' _units field, then sort by -// the amount if the units are equal. +// Compare two memory reporter nodes. The primary sort is on the _units +// property. The secondary sort is on the _path property if the _units is +// UNIT_COUNT, otherwise it is on the _amount property. function cmpAmount(a, b) { - if (a._units != b._units) + if (a._units != b._units) { return a._units - b._units; // use the enum order from nsIMemoryReporter - else - return b._amount - a._amount; + } + if (a._units == UNITS_COUNT) { + if (a._path < b._path) + return -1; + if (a._path > b._path) + return 1; + return 0; + } + return b._amount - a._amount; }; /** diff --git a/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul b/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul index 602032589f3..922b88c52dd 100644 --- a/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul +++ b/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul @@ -192,8 +192,8 @@ Other Measurements\n\ 222.00 MB -- other2\n\ 111.00 MB -- other1\n\ 100.00 MB -- heap-unused\n\ - 888 -- other4\n\ 777 -- other3\n\ + 888 -- other4\n\ (???) -- unknown-unit\n\ \n\ 2nd Process\n\ @@ -263,8 +263,8 @@ Other Measurements\n\ 232,783,872 B -- other2\n\ 116,391,936 B -- other1\n\ 104,857,600 B -- heap-unused\n\ - 888 -- other4\n\ 777 -- other3\n\ + 888 -- other4\n\ (???) -- unknown-unit\n\ \n\ 2nd Process\n\ diff --git a/toolkit/components/telemetry/TelemetryHistograms.h b/toolkit/components/telemetry/TelemetryHistograms.h index 65e5e572a43..77c675fc478 100644 --- a/toolkit/components/telemetry/TelemetryHistograms.h +++ b/toolkit/components/telemetry/TelemetryHistograms.h @@ -64,7 +64,7 @@ HISTOGRAM(GLUESTARTUP_READ_TRANSFER, 1, 50 * 1024, 12, EXPONENTIAL, "ProcessIoCo #elif defined(XP_UNIX) HISTOGRAM(EARLY_GLUESTARTUP_HARD_FAULTS, 1, 100, 12, LINEAR, "Hard faults count before glue startup") HISTOGRAM(GLUESTARTUP_HARD_FAULTS, 1, 500, 12, EXPONENTIAL, "Hard faults count after glue startup") -HISTOGRAM(HARD_PAGE_FAULTS, 8, 64 * 1024, 13, EXPONENTIAL, "Hard page faults (since last telemetry ping)") +HISTOGRAM(PAGE_FAULTS_HARD, 8, 64 * 1024, 13, EXPONENTIAL, "Hard page faults (since last telemetry ping)") #endif HISTOGRAM(ZIPARCHIVE_CRC, 0, 1, 2, BOOLEAN, "Zip item CRC check pass") HISTOGRAM(SHUTDOWN_OK, 0, 1, 2, BOOLEAN, "Did the browser start after a successful shutdown") diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index 19d71e0bb4e..aa458429f70 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -60,7 +60,7 @@ const MEM_HISTOGRAMS = { "explicit/images/content/used/uncompressed": "MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED", "heap-used": "MEMORY_HEAP_USED", - "hard-page-faults": "HARD_PAGE_FAULTS" + "page-faults-hard": "PAGE_FAULTS_HARD" }; XPCOMUtils.defineLazyGetter(this, "Telemetry", function () { diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 3983dca8e7d..d60179813d4 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -206,8 +206,8 @@ NS_MEMORY_REPORTER_IMPLEMENT(Vsize, #endif #if defined(XP_LINUX) || defined(XP_MACOSX) -NS_MEMORY_REPORTER_IMPLEMENT(SoftPageFaults, - "soft-page-faults", +NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsSoft, + "page-faults-soft", KIND_OTHER, UNITS_COUNT, GetSoftPageFaults, @@ -221,8 +221,8 @@ NS_MEMORY_REPORTER_IMPLEMENT(SoftPageFaults, "and because the OS services a soft page fault without accessing the disk, " "they impact performance much less than hard page faults.") -NS_MEMORY_REPORTER_IMPLEMENT(HardPageFaults, - "hard-page-faults", +NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsHard, + "page-faults-hard", KIND_OTHER, UNITS_COUNT, GetHardPageFaults, @@ -421,8 +421,8 @@ nsMemoryReporterManager::Init() #endif #if defined(XP_LINUX) || defined(XP_MACOSX) - REGISTER(SoftPageFaults); - REGISTER(HardPageFaults); + REGISTER(PageFaultsSoft); + REGISTER(PageFaultsHard); #endif #if defined(XP_WIN) && MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN