From 6255af99a86f72a95c2347514a9d833df2d3ade5 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Fri, 15 Feb 2019 16:04:32 +0100 Subject: [PATCH] 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 Commit-Queue: Ilya Nikolaevskiy Reviewed-by: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/master@{#26712} --- .../pc/e2e/analyzer/video/default_video_quality_analyzer.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index c3bf685d97..e4fcd209f5 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -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(event_count_) / - (event_last_time_ - event_first_time_).seconds(); + (event_last_time_ - event_first_time_).us() * kMicrosPerSecond; } DefaultVideoQualityAnalyzer::DefaultVideoQualityAnalyzer(std::string test_label)