Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Unified Diff: base/metrics/statistics_recorder.cc

Issue 1618703007: Sort histograms by name before displaying them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/statistics_recorder.cc
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index 15e48d8ae622d3572467c93800a0b4caf6547c21..b18efad280abed4582f8dae10dbea93c255b6876 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -17,9 +17,16 @@
#include "base/values.h"
namespace {
+
// Initialize histogram statistics gathering system.
base::LazyInstance<base::StatisticsRecorder>::Leaky g_statistics_recorder_ =
LAZY_INSTANCE_INITIALIZER;
+
+bool HistogramNameLesser(const base::HistogramBase* a,
+ const base::HistogramBase* b) {
+ return a->histogram_name() < b->histogram_name();
+}
+
} // namespace
namespace base {
@@ -142,6 +149,7 @@ void StatisticsRecorder::WriteHTMLGraph(const std::string& query,
Histograms snapshot;
GetSnapshot(query, &snapshot);
+ std::sort(snapshot.begin(), snapshot.end(), &HistogramNameLesser);
for (const HistogramBase* histogram : snapshot) {
histogram->WriteHTMLGraph(output);
output->append("<br><hr><br>");
@@ -160,6 +168,7 @@ void StatisticsRecorder::WriteGraph(const std::string& query,
Histograms snapshot;
GetSnapshot(query, &snapshot);
+ std::sort(snapshot.begin(), snapshot.end(), &HistogramNameLesser);
for (const HistogramBase* histogram : snapshot) {
histogram->WriteAscii(output);
output->append("\n");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698