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: components/metrics/histogram_encoder.cc

Issue 1744283002: Optimizations to histogram protobuf encoding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment. Created 4 years, 10 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 | components/metrics/proto/histogram_event.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/histogram_encoder.cc
diff --git a/components/metrics/histogram_encoder.cc b/components/metrics/histogram_encoder.cc
index f816807db92eeda67c55a862fc7d101e12ae8e4f..595fb5398674c9321a543a0d3b83c9836357365f 100644
--- a/components/metrics/histogram_encoder.cc
+++ b/components/metrics/histogram_encoder.cc
@@ -25,7 +25,8 @@ void EncodeHistogramDelta(const std::string& histogram_name,
HistogramEventProto* histogram_proto = uma_proto->add_histogram_event();
histogram_proto->set_name_hash(base::HashMetricName(histogram_name));
- histogram_proto->set_sum(snapshot.sum());
+ if (snapshot.sum() != 0)
+ histogram_proto->set_sum(snapshot.sum());
for (scoped_ptr<SampleCountIterator> it = snapshot.Iterator(); !it->Done();
it->Next()) {
@@ -36,7 +37,9 @@ void EncodeHistogramDelta(const std::string& histogram_name,
HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket();
bucket->set_min(min);
bucket->set_max(max);
- bucket->set_count(count);
+ // Note: The default for count is 1 in the proto, so omit it in that case.
+ if (count != 1)
+ bucket->set_count(count);
}
// Omit fields to save space (see rules in histogram_event.proto comments).
« no previous file with comments | « no previous file | components/metrics/proto/histogram_event.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698