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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/logging/stats_event_subscriber.h" 5 #include "media/cast/logging/stats_event_subscriber.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void StatsEventSubscriber::SimpleHistogram::Reset() { 58 void StatsEventSubscriber::SimpleHistogram::Reset() {
59 buckets_.assign(buckets_.size(), 0); 59 buckets_.assign(buckets_.size(), 0);
60 } 60 }
61 61
62 scoped_ptr<base::ListValue> 62 scoped_ptr<base::ListValue>
63 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { 63 StatsEventSubscriber::SimpleHistogram::GetHistogram() const {
64 scoped_ptr<base::ListValue> histo(new base::ListValue); 64 scoped_ptr<base::ListValue> histo(new base::ListValue);
65 65
66 scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue); 66 scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue);
67 67
68 bucket->SetString("bucket", base::StringPrintf("< %" PRId64, min_)); 68 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.
69 bucket->SetInteger("count", buckets_.front()); 69 buckets_.front());
70 histo->Append(bucket.release()); 70 histo->Append(bucket.release());
71 71
72 for (size_t i = 1; i < buckets_.size() - 1; i++) { 72 size_t index = 1;
73 while (index < buckets_.size() - 1) {
73 bucket.reset(new base::DictionaryValue); 74 bucket.reset(new base::DictionaryValue);
75 size_t end_index = index;
74 76
75 int64 lower = min_ + (i - 1) * width_; 77 // Find as many consecutive zero buckets as possible.
76 int64 upper = lower + width_ - 1; 78 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.
77 bucket->SetString( 79 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.
78 "bucket", base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper)); 80 ++end_index;
79 bucket->SetInteger("count", buckets_[i]); 81 }
82 int64 lower = min_ + (index - 1) * width_;
83 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.
84 bucket->SetInteger(
85 base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper),
86 buckets_[index]);
87 index = end_index + 1;
80 histo->Append(bucket.release()); 88 histo->Append(bucket.release());
81 } 89 }
82 90
83 bucket.reset(new base::DictionaryValue); 91 bucket.reset(new base::DictionaryValue);
84 92 bucket->SetInteger(base::StringPrintf(">= %" PRId64, max_),
85 bucket->SetString("bucket", base::StringPrintf(">= %" PRId64, max_)); 93 buckets_.back());
86 bucket->SetInteger("count", buckets_.back());
87 histo->Append(bucket.release()); 94 histo->Append(bucket.release());
88 95
89 return histo.Pass(); 96 return histo.Pass();
90 } 97 }
91 98
92 StatsEventSubscriber::StatsEventSubscriber( 99 StatsEventSubscriber::StatsEventSubscriber(
93 EventMediaType event_media_type, 100 EventMediaType event_media_type,
94 base::TickClock* clock, 101 base::TickClock* clock,
95 ReceiverTimeOffsetEstimator* offset_estimator) 102 ReceiverTimeOffsetEstimator* offset_estimator)
96 : event_media_type_(event_media_type), 103 : event_media_type_(event_media_type),
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 : event_counter(0), sum_size(0) {} 656 : event_counter(0), sum_size(0) {}
650 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} 657 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {}
651 658
652 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { 659 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) {
653 } 660 }
654 StatsEventSubscriber::FrameInfo::~FrameInfo() { 661 StatsEventSubscriber::FrameInfo::~FrameInfo() {
655 } 662 }
656 663
657 } // namespace cast 664 } // namespace cast
658 } // namespace media 665 } // namespace media
OLDNEW
« 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