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

Unified Diff: base/metrics/histogram_base.cc

Issue 13469020: Implement write methods for SparseHistogram (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase due to conflict in histogram_base.cc Created 7 years, 8 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 | « base/metrics/histogram_base.h ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_base.cc
diff --git a/base/metrics/histogram_base.cc b/base/metrics/histogram_base.cc
index 5272d0390af02f7e9ad18b314358080ff3420b2d..51689a80336521626920b900030a5184572ead26 100644
--- a/base/metrics/histogram_base.cc
+++ b/base/metrics/histogram_base.cc
@@ -14,6 +14,7 @@
#include "base/metrics/sparse_histogram.h"
#include "base/pickle.h"
#include "base/process_util.h"
+#include "base/stringprintf.h"
#include "base/values.h"
namespace base {
@@ -124,4 +125,35 @@ void HistogramBase::WriteJSON(std::string* output) const {
serializer.Serialize(root);
}
+void HistogramBase::WriteAsciiBucketGraph(double current_size,
+ double max_size,
+ std::string* output) const {
+ const int k_line_length = 72; // Maximal horizontal width of graph.
+ int x_count = static_cast<int>(k_line_length * (current_size / max_size)
+ + 0.5);
+ int x_remainder = k_line_length - x_count;
+
+ while (0 < x_count--)
+ output->append("-");
+ output->append("O");
+ while (0 < x_remainder--)
+ output->append(" ");
+}
+
+const std::string HistogramBase::GetSimpleAsciiBucketRange(
+ Sample sample) const {
+ std::string result;
+ if (kHexRangePrintingFlag & flags())
+ StringAppendF(&result, "%#x", sample);
+ else
+ StringAppendF(&result, "%d", sample);
+ return result;
+}
+
+void HistogramBase::WriteAsciiBucketValue(Count current,
+ double scaled_sum,
+ std::string* output) const {
+ StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum);
+}
+
} // namespace base
« no previous file with comments | « base/metrics/histogram_base.h ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698