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

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: remove 0 buckets 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..b22812e446e7fa69240289bdea72e903041492b1 100644
--- a/media/cast/logging/stats_event_subscriber.cc
+++ b/media/cast/logging/stats_event_subscriber.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <cmath>
+
#include "media/cast/logging/stats_event_subscriber.h"
#include "base/format_macros.h"
@@ -65,27 +67,30 @@ StatsEventSubscriber::SimpleHistogram::GetHistogram() const {
scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue);
- bucket->SetString("bucket", base::StringPrintf("< %" PRId64, min_));
- bucket->SetInteger("count", buckets_.front());
- histo->Append(bucket.release());
+ if (buckets_.front()) {
+ bucket->SetInteger(base::StringPrintf("<%" PRId64, min_),
+ buckets_.front());
+ histo->Append(bucket.release());
+ }
for (size_t i = 1; i < buckets_.size() - 1; i++) {
+ if (!buckets_[i])
+ continue;
bucket.reset(new base::DictionaryValue);
-
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]);
+ bucket->SetInteger(
+ base::StringPrintf("%" PRId64 "-%" PRId64, lower, upper),
+ buckets_[i]);
histo->Append(bucket.release());
}
- bucket.reset(new base::DictionaryValue);
-
- bucket->SetString("bucket", base::StringPrintf(">= %" PRId64, max_));
- bucket->SetInteger("count", buckets_.back());
- histo->Append(bucket.release());
-
+ if (buckets_.back()) {
+ bucket.reset(new base::DictionaryValue);
+ bucket->SetInteger(base::StringPrintf(">=%" PRId64, max_),
+ buckets_.back());
+ histo->Append(bucket.release());
+ }
return histo.Pass();
}
@@ -217,7 +222,9 @@ scoped_ptr<base::DictionaryValue> StatsEventSubscriber::GetStats() const {
scoped_ptr<base::DictionaryValue> stats(new base::DictionaryValue);
for (StatsMap::const_iterator it = stats_map.begin(); it != stats_map.end();
++it) {
- stats->SetDouble(CastStatToString(it->first), it->second);
+ // Round to 3 digits after the decimal point.
+ stats->SetDouble(CastStatToString(it->first),
+ round(it->second * 1000.0) / 1000.0);
}
for (HistogramMap::const_iterator it = histograms_.begin();
it != histograms_.end();
« 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