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

Unified Diff: media/cast/logging/stats_event_subscriber.cc

Issue 582253002: Cast: Reduce the size of stats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more space saving Created 6 years, 3 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: media/cast/logging/stats_event_subscriber.cc
diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc
index b9cf26532f24e89b4e82f64e7c12e3e4e87069d5..b74949a5a32411600fda85493a2b8b5cf694dea5 100644
--- a/media/cast/logging/stats_event_subscriber.cc
+++ b/media/cast/logging/stats_event_subscriber.cc
@@ -65,25 +65,32 @@ StatsEventSubscriber::SimpleHistogram::GetHistogram() const {
scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue);
- bucket->SetString("bucket", base::StringPrintf("< %" PRId64, min_));
- bucket->SetInteger("count", buckets_.front());
+ bucket->SetInteger(base::StringPrintf("< %" PRId64, min_),
imcheng 2014/09/19 20:48:14 I think you can also get rid of the spaces between
Alpha Left Google 2014/09/19 20:57:55 Done.
+ buckets_.front());
histo->Append(bucket.release());
- for (size_t i = 1; i < buckets_.size() - 1; i++) {
+ size_t index = 1;
+ while (index < buckets_.size() - 1) {
bucket.reset(new base::DictionaryValue);
+ size_t end_index = index;
- int64 lower = min_ + (i - 1) * width_;
- int64 upper = lower + width_ - 1;
- bucket->SetString(
- "bucket", base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper));
- bucket->SetInteger("count", buckets_[i]);
+ // Find as many consecutive zero buckets as possible.
+ if (!buckets_[index]) {
imcheng 2014/09/19 20:52:33 nit: prefer explicitly checking != 0.
Alpha Left Google 2014/09/19 20:57:55 Done.
+ while (end_index + 2 < buckets_.size() && !buckets_[end_index + 1])
imcheng 2014/09/19 20:52:33 ditto
Alpha Left Google 2014/09/19 20:57:55 Done.
+ ++end_index;
+ }
+ int64 lower = min_ + (index - 1) * width_;
+ int64 upper = min_ + end_index * width_ - 1;
imcheng 2014/09/19 20:52:33 Shouldn't this be min_ + (end_index - index) * wid
imcheng 2014/09/19 20:53:56 Never mind, I misread this.
+ bucket->SetInteger(
+ base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper),
+ buckets_[index]);
+ index = end_index + 1;
histo->Append(bucket.release());
}
bucket.reset(new base::DictionaryValue);
-
- bucket->SetString("bucket", base::StringPrintf(">= %" PRId64, max_));
- bucket->SetInteger("count", buckets_.back());
+ bucket->SetInteger(base::StringPrintf(">= %" PRId64, max_),
+ buckets_.back());
histo->Append(bucket.release());
return histo.Pass();
« 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