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

Side by Side Diff: webrtc/video/stats_counter.h

Issue 2388043003: Make process interval configurable for MaxCounter class. (Closed)
Patch Set: Created 4 years, 2 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 | webrtc/video/stats_counter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // Reports metrics for elapsed intervals to AggregatedCounter and pauses stats 93 // Reports metrics for elapsed intervals to AggregatedCounter and pauses stats
94 // (i.e. empty intervals will be discarded until next sample is added). 94 // (i.e. empty intervals will be discarded until next sample is added).
95 void ProcessAndPause(); 95 void ProcessAndPause();
96 96
97 // Checks if a sample has been added (i.e. Add or Set called). 97 // Checks if a sample has been added (i.e. Add or Set called).
98 bool HasSample() const; 98 bool HasSample() const;
99 99
100 protected: 100 protected:
101 StatsCounter(Clock* clock, 101 StatsCounter(Clock* clock,
102 int64_t process_intervals_ms,
102 bool include_empty_intervals, 103 bool include_empty_intervals,
103 StatsCounterObserver* observer); 104 StatsCounterObserver* observer);
104 105
105 void Add(int sample); 106 void Add(int sample);
106 void Set(int sample); 107 void Set(int sample);
107 108
108 int max_; 109 int max_;
109 int64_t sum_; 110 int64_t sum_;
110 int64_t num_samples_; 111 int64_t num_samples_;
111 int64_t last_sum_; 112 int64_t last_sum_;
112 113
113 const std::unique_ptr<AggregatedCounter> aggregated_counter_; 114 const std::unique_ptr<AggregatedCounter> aggregated_counter_;
115 const int64_t process_intervals_ms_;
114 116
115 private: 117 private:
116 bool TimeToProcess(int* num_elapsed_intervals); 118 bool TimeToProcess(int* num_elapsed_intervals);
117 void TryProcess(); 119 void TryProcess();
118 void ReportMetricToAggregatedCounter(int value, int num_values_to_add) const; 120 void ReportMetricToAggregatedCounter(int value, int num_values_to_add) const;
119 bool IncludeEmptyIntervals() const; 121 bool IncludeEmptyIntervals() const;
120 122
121 Clock* const clock_; 123 Clock* const clock_;
122 const bool include_empty_intervals_; 124 const bool include_empty_intervals_;
123 const std::unique_ptr<StatsCounterObserver> observer_; 125 const std::unique_ptr<StatsCounterObserver> observer_;
(...skipping 30 matching lines...) Expand all
154 }; 156 };
155 157
156 // MaxCounter: maximum of samples 158 // MaxCounter: maximum of samples
157 // 159 //
158 // | * * * | * * | ... 160 // | * * * | * * | ...
159 // | Add(5) Add(1) Add(6) | Add(5) Add(5) | 161 // | Add(5) Add(1) Add(6) | Add(5) Add(5) |
160 // GetMetric | max: (5, 1, 6) | max: (5, 5) | 162 // GetMetric | max: (5, 1, 6) | max: (5, 5) |
161 // 163 //
162 class MaxCounter : public StatsCounter { 164 class MaxCounter : public StatsCounter {
163 public: 165 public:
164 MaxCounter(Clock* clock, StatsCounterObserver* observer); 166 MaxCounter(Clock* clock,
167 StatsCounterObserver* observer,
168 int64_t process_intervals_ms);
165 ~MaxCounter() override {} 169 ~MaxCounter() override {}
166 170
167 void Add(int sample); 171 void Add(int sample);
168 172
169 private: 173 private:
170 bool GetMetric(int* metric) const override; 174 bool GetMetric(int* metric) const override;
171 int GetValueForEmptyInterval() const override; 175 int GetValueForEmptyInterval() const override;
172 176
173 RTC_DISALLOW_COPY_AND_ASSIGN(MaxCounter); 177 RTC_DISALLOW_COPY_AND_ASSIGN(MaxCounter);
174 }; 178 };
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 private: 267 private:
264 bool GetMetric(int* metric) const override; 268 bool GetMetric(int* metric) const override;
265 int GetValueForEmptyInterval() const override; // Returns zero. 269 int GetValueForEmptyInterval() const override; // Returns zero.
266 270
267 RTC_DISALLOW_COPY_AND_ASSIGN(RateAccCounter); 271 RTC_DISALLOW_COPY_AND_ASSIGN(RateAccCounter);
268 }; 272 };
269 273
270 } // namespace webrtc 274 } // namespace webrtc
271 275
272 #endif // WEBRTC_VIDEO_STATS_COUNTER_H_ 276 #endif // WEBRTC_VIDEO_STATS_COUNTER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/stats_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698