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

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: nothing 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 | « media/cast/logging/stats_event_subscriber.h ('k') | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 size_t index = 1 + (sample - min_) / width_; 52 size_t index = 1 + (sample - min_) / width_;
53 DCHECK_LT(index, buckets_.size()); 53 DCHECK_LT(index, buckets_.size());
54 ++buckets_[index]; 54 ++buckets_[index];
55 } 55 }
56 } 56 }
57 57
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::DictionaryValue>
imcheng 2014/09/18 22:06:20 The problem with this approach is that the buckets
63 StatsEventSubscriber::SimpleHistogram::GetHistogram() const { 63 StatsEventSubscriber::SimpleHistogram::GetHistogram() const {
64 scoped_ptr<base::ListValue> histo(new base::ListValue); 64 scoped_ptr<base::DictionaryValue> histo(new base::DictionaryValue);
65 65 histo->SetInteger(base::StringPrintf("< %" PRId64, min_), buckets_.front());
66 scoped_ptr<base::DictionaryValue> bucket(new base::DictionaryValue);
67
68 bucket->SetString("bucket", base::StringPrintf("< %" PRId64, min_));
69 bucket->SetInteger("count", buckets_.front());
70 histo->Append(bucket.release());
71 66
72 for (size_t i = 1; i < buckets_.size() - 1; i++) { 67 for (size_t i = 1; i < buckets_.size() - 1; i++) {
73 bucket.reset(new base::DictionaryValue);
74
75 int64 lower = min_ + (i - 1) * width_; 68 int64 lower = min_ + (i - 1) * width_;
76 int64 upper = lower + width_ - 1; 69 int64 upper = lower + width_ - 1;
77 bucket->SetString( 70 histo->SetInteger(
78 "bucket", base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper)); 71 base::StringPrintf("%" PRId64 " - %" PRId64, lower, upper),
79 bucket->SetInteger("count", buckets_[i]); 72 buckets_[i]);
80 histo->Append(bucket.release());
81 } 73 }
82 74
83 bucket.reset(new base::DictionaryValue); 75 histo->SetInteger(base::StringPrintf(">= %" PRId64, max_), buckets_.back());
84
85 bucket->SetString("bucket", base::StringPrintf(">= %" PRId64, max_));
86 bucket->SetInteger("count", buckets_.back());
87 histo->Append(bucket.release());
88
89 return histo.Pass(); 76 return histo.Pass();
90 } 77 }
91 78
92 StatsEventSubscriber::StatsEventSubscriber( 79 StatsEventSubscriber::StatsEventSubscriber(
93 EventMediaType event_media_type, 80 EventMediaType event_media_type,
94 base::TickClock* clock, 81 base::TickClock* clock,
95 ReceiverTimeOffsetEstimator* offset_estimator) 82 ReceiverTimeOffsetEstimator* offset_estimator)
96 : event_media_type_(event_media_type), 83 : event_media_type_(event_media_type),
97 clock_(clock), 84 clock_(clock),
98 offset_estimator_(offset_estimator), 85 offset_estimator_(offset_estimator),
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 : event_counter(0), sum_size(0) {} 636 : event_counter(0), sum_size(0) {}
650 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {} 637 StatsEventSubscriber::PacketLogStats::~PacketLogStats() {}
651 638
652 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) { 639 StatsEventSubscriber::FrameInfo::FrameInfo() : encoded(false) {
653 } 640 }
654 StatsEventSubscriber::FrameInfo::~FrameInfo() { 641 StatsEventSubscriber::FrameInfo::~FrameInfo() {
655 } 642 }
656 643
657 } // namespace cast 644 } // namespace cast
658 } // namespace media 645 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/logging/stats_event_subscriber.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698