diff options
author | hclam <hclam@chromium.org> | 2014-09-23 17:05:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-24 00:06:02 +0000 |
commit | 94f57a1781b0749fdb7884a9b3b7036e58b1908c (patch) | |
tree | 4574059986d8869c640b5311f0d8509a67e70d53 /media | |
parent | a5d6f7b3f5502e7af7a4648ef75a4f10f38fc9e9 (diff) | |
download | chromium_src-94f57a1781b0749fdb7884a9b3b7036e58b1908c.zip chromium_src-94f57a1781b0749fdb7884a9b3b7036e58b1908c.tar.gz chromium_src-94f57a1781b0749fdb7884a9b3b7036e58b1908c.tar.bz2 |
Cast: Reduce the size of stats
Stats generated by cast streaming API contains some redundancy stuff
like "bucket" and "count".
Also remove 0 buckets in the stats to reduce size.
Review URL: https://codereview.chromium.org/582253002
Cr-Commit-Position: refs/heads/master@{#296309}
Diffstat (limited to 'media')
-rw-r--r-- | media/cast/logging/stats_event_subscriber.cc | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc index b9cf265..b22812e 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(); |