| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Log the average for the current (incomplete) interval. | 88 // Log the average for the current (incomplete) interval. |
| 89 LogToUma(Metric()); | 89 LogToUma(Metric()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void StatisticsCalculator::PeriodicUmaAverage::RegisterSample(int value) { | 92 void StatisticsCalculator::PeriodicUmaAverage::RegisterSample(int value) { |
| 93 sum_ += value; | 93 sum_ += value; |
| 94 ++counter_; | 94 ++counter_; |
| 95 } | 95 } |
| 96 | 96 |
| 97 int StatisticsCalculator::PeriodicUmaAverage::Metric() const { | 97 int StatisticsCalculator::PeriodicUmaAverage::Metric() const { |
| 98 return static_cast<int>(sum_ / counter_); | 98 return counter_ == 0 ? 0 : static_cast<int>(sum_ / counter_); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void StatisticsCalculator::PeriodicUmaAverage::Reset() { | 101 void StatisticsCalculator::PeriodicUmaAverage::Reset() { |
| 102 sum_ = 0.0; | 102 sum_ = 0.0; |
| 103 counter_ = 0; | 103 counter_ = 0; |
| 104 } | 104 } |
| 105 | 105 |
| 106 StatisticsCalculator::StatisticsCalculator() | 106 StatisticsCalculator::StatisticsCalculator() |
| 107 : preemptive_samples_(0), | 107 : preemptive_samples_(0), |
| 108 accelerate_samples_(0), | 108 accelerate_samples_(0), |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Ratio must be smaller than 1 in Q14. | 287 // Ratio must be smaller than 1 in Q14. |
| 288 assert((numerator << 14) / denominator < (1 << 14)); | 288 assert((numerator << 14) / denominator < (1 << 14)); |
| 289 return static_cast<uint16_t>((numerator << 14) / denominator); | 289 return static_cast<uint16_t>((numerator << 14) / denominator); |
| 290 } else { | 290 } else { |
| 291 // Will not produce a ratio larger than 1, since this is probably an error. | 291 // Will not produce a ratio larger than 1, since this is probably an error. |
| 292 return 1 << 14; | 292 return 1 << 14; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace webrtc | 296 } // namespace webrtc |
| OLD | NEW |