Fix RateCounter to don't fail if there are too small amount of events
Bug: webrtc:10138 Change-Id: Iac26e4948b92810245c16b8c46b4b3e70850505e Reviewed-on: https://webrtc-review.googlesource.com/c/123193 Commit-Queue: Artem Titov <titovartem@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26712}
This commit is contained in:
@ -25,6 +25,7 @@ namespace {
|
||||
|
||||
constexpr int kMaxActiveComparisons = 10;
|
||||
constexpr int kFreezeThresholdMs = 150;
|
||||
constexpr int kMicrosPerSecond = 1000000;
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -38,8 +39,11 @@ void RateCounter::AddEvent(Timestamp event_time) {
|
||||
|
||||
double RateCounter::GetEventsPerSecond() const {
|
||||
RTC_DCHECK(!IsEmpty());
|
||||
// Divide on us and multiply on kMicrosPerSecond to correctly process cases
|
||||
// where there were too small amount of events, so difference is less then 1
|
||||
// sec. We can use us here, because Timestamp has us resolution.
|
||||
return static_cast<double>(event_count_) /
|
||||
(event_last_time_ - event_first_time_).seconds();
|
||||
(event_last_time_ - event_first_time_).us() * kMicrosPerSecond;
|
||||
}
|
||||
|
||||
DefaultVideoQualityAnalyzer::DefaultVideoQualityAnalyzer(std::string test_label)
|
||||
|
Reference in New Issue
Block a user