From eb02a76b364ba9fae4ed325ae91eb8edc9507341 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Mon, 15 Apr 2019 16:20:44 +0200 Subject: [PATCH] Allow negative delta in EventRateCounter. Bug: webrtc:10365 Change-Id: I13192d1e179ef5637210cfea3e67010d00117957 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133025 Reviewed-by: Rasmus Brandt Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#27637} --- test/scenario/performance_stats.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/scenario/performance_stats.cc b/test/scenario/performance_stats.cc index 3ff66cd10c..3471cbe0e1 100644 --- a/test/scenario/performance_stats.cc +++ b/test/scenario/performance_stats.cc @@ -14,13 +14,10 @@ namespace webrtc { namespace test { void EventRateCounter::AddEvent(Timestamp event_time) { - if (first_time_.IsInfinite()) { - first_time_ = event_time; - } else { - RTC_DCHECK(event_time >= last_time_); + if (first_time_.IsFinite()) interval_.AddSample(event_time - last_time_); - } - last_time_ = event_time; + first_time_ = std::min(first_time_, event_time); + last_time_ = std::max(last_time_, event_time); event_count_++; }