OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 observer_(observer), | 67 observer_(observer), |
68 aggregated_counter_(new AggregatedCounter()), | 68 aggregated_counter_(new AggregatedCounter()), |
69 last_process_time_ms_(-1) {} | 69 last_process_time_ms_(-1) {} |
70 | 70 |
71 StatsCounter::~StatsCounter() {} | 71 StatsCounter::~StatsCounter() {} |
72 | 72 |
73 AggregatedStats StatsCounter::GetStats() { | 73 AggregatedStats StatsCounter::GetStats() { |
74 return aggregated_counter_->ComputeStats(); | 74 return aggregated_counter_->ComputeStats(); |
75 } | 75 } |
76 | 76 |
| 77 bool StatsCounter::HasSample() const { |
| 78 return last_process_time_ms_ != -1; |
| 79 } |
| 80 |
77 bool StatsCounter::TimeToProcess() { | 81 bool StatsCounter::TimeToProcess() { |
78 int64_t now = clock_->TimeInMilliseconds(); | 82 int64_t now = clock_->TimeInMilliseconds(); |
79 if (last_process_time_ms_ == -1) | 83 if (last_process_time_ms_ == -1) |
80 last_process_time_ms_ = now; | 84 last_process_time_ms_ = now; |
81 | 85 |
82 int64_t diff_ms = now - last_process_time_ms_; | 86 int64_t diff_ms = now - last_process_time_ms_; |
83 if (diff_ms < kProcessIntervalMs) | 87 if (diff_ms < kProcessIntervalMs) |
84 return false; | 88 return false; |
85 | 89 |
86 // Advance number of complete kProcessIntervalMs that have passed. | 90 // Advance number of complete kProcessIntervalMs that have passed. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 226 |
223 bool RateAccCounter::GetMetric(int* metric) const { | 227 bool RateAccCounter::GetMetric(int* metric) const { |
224 if (num_samples_ == 0 || last_sum_ > sum_) | 228 if (num_samples_ == 0 || last_sum_ > sum_) |
225 return false; | 229 return false; |
226 *metric = | 230 *metric = |
227 ((sum_ - last_sum_) * 1000 + kProcessIntervalMs / 2) / kProcessIntervalMs; | 231 ((sum_ - last_sum_) * 1000 + kProcessIntervalMs / 2) / kProcessIntervalMs; |
228 return true; | 232 return true; |
229 } | 233 } |
230 | 234 |
231 } // namespace webrtc | 235 } // namespace webrtc |
OLD | NEW |