Keep microseconds when computing e2e test time results

Using ms() was converting the value to an int before putting it into a
double, causing the microseconds to be dropped. This has the most impact
on decode time metrics which are ofter less than 1ms.

Bug: webrtc:14339
Change-Id: Ie8401ba5a46eb3b35e8a699acfdad2dcd32a8240
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271163
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37734}
This commit is contained in:
Evan Shrubsole
2022-08-10 13:32:26 +00:00
committed by WebRTC LUCI CQ
parent 9d8fdc7bf7
commit 53cc9adfe2
2 changed files with 34 additions and 31 deletions

View File

@ -30,7 +30,7 @@
namespace webrtc { namespace webrtc {
namespace { namespace {
constexpr int kFreezeThresholdMs = 150; constexpr TimeDelta kFreezeThreshold = TimeDelta::Millis(150);
constexpr int kMaxActiveComparisons = 10; constexpr int kMaxActiveComparisons = 10;
SamplesStatsCounter::StatsSample StatsSample(double value, SamplesStatsCounter::StatsSample StatsSample(double value,
@ -38,6 +38,11 @@ SamplesStatsCounter::StatsSample StatsSample(double value,
return SamplesStatsCounter::StatsSample{value, sampling_time}; return SamplesStatsCounter::StatsSample{value, sampling_time};
} }
SamplesStatsCounter::StatsSample StatsSample(TimeDelta duration,
Timestamp sampling_time) {
return SamplesStatsCounter::StatsSample{duration.ms<double>(), sampling_time};
}
FrameComparison ValidateFrameComparison(FrameComparison comparison) { FrameComparison ValidateFrameComparison(FrameComparison comparison) {
RTC_DCHECK(comparison.frame_stats.captured_time.IsFinite()) RTC_DCHECK(comparison.frame_stats.captured_time.IsFinite())
<< "Any comparison has to have finite captured_time"; << "Any comparison has to have finite captured_time";
@ -212,9 +217,8 @@ void DefaultVideoQualityAnalyzerFramesComparator::Stop(
// `last_rendered_frame_time` for this stream will be stream start time. // `last_rendered_frame_time` for this stream will be stream start time.
// If there is freeze, then we need add time from last rendered frame // If there is freeze, then we need add time from last rendered frame
// to last freeze end as time between freezes. // to last freeze end as time between freezes.
stream_stats_.at(stats_key).time_between_freezes_ms.AddSample( stream_stats_.at(stats_key).time_between_freezes_ms.AddSample(StatsSample(
StatsSample(last_rendered_frame_time.ms() - last_rendered_frame_time - stream_last_freeze_end_time_.at(stats_key),
stream_last_freeze_end_time_.at(stats_key).ms(),
Now())); Now()));
} }
} }
@ -422,8 +426,8 @@ void DefaultVideoQualityAnalyzerFramesComparator::ProcessComparison(
} }
if (frame_stats.encoded_time.IsFinite()) { if (frame_stats.encoded_time.IsFinite()) {
stats->encode_time_ms.AddSample(StatsSample( stats->encode_time_ms.AddSample(
(frame_stats.encoded_time - frame_stats.pre_encode_time).ms(), StatsSample(frame_stats.encoded_time - frame_stats.pre_encode_time,
frame_stats.encoded_time)); frame_stats.encoded_time));
stats->encode_frame_rate.AddEvent(frame_stats.encoded_time); stats->encode_frame_rate.AddEvent(frame_stats.encoded_time);
stats->total_encoded_images_payload += stats->total_encoded_images_payload +=
@ -443,16 +447,16 @@ void DefaultVideoQualityAnalyzerFramesComparator::ProcessComparison(
StatsSample(*comparison.frame_stats.rendered_frame_width * StatsSample(*comparison.frame_stats.rendered_frame_width *
*comparison.frame_stats.rendered_frame_height, *comparison.frame_stats.rendered_frame_height,
frame_stats.rendered_time)); frame_stats.rendered_time));
stats->total_delay_incl_transport_ms.AddSample(StatsSample( stats->total_delay_incl_transport_ms.AddSample(
(frame_stats.rendered_time - frame_stats.captured_time).ms(), StatsSample(frame_stats.rendered_time - frame_stats.captured_time,
frame_stats.received_time)); frame_stats.received_time));
stats->receive_to_render_time_ms.AddSample(StatsSample( stats->receive_to_render_time_ms.AddSample(
(frame_stats.rendered_time - frame_stats.received_time).ms(), StatsSample(frame_stats.rendered_time - frame_stats.received_time,
frame_stats.rendered_time)); frame_stats.rendered_time));
} }
if (frame_stats.decode_start_time.IsFinite()) { if (frame_stats.decode_start_time.IsFinite()) {
stats->transport_time_ms.AddSample(StatsSample( stats->transport_time_ms.AddSample(
(frame_stats.decode_start_time - frame_stats.encoded_time).ms(), StatsSample(frame_stats.decode_start_time - frame_stats.encoded_time,
frame_stats.decode_start_time)); frame_stats.decode_start_time));
// Stats sliced on decoded frame type. // Stats sliced on decoded frame type.
@ -471,7 +475,7 @@ void DefaultVideoQualityAnalyzerFramesComparator::ProcessComparison(
} }
if (frame_stats.decode_end_time.IsFinite()) { if (frame_stats.decode_end_time.IsFinite()) {
stats->decode_time_ms.AddSample(StatsSample( stats->decode_time_ms.AddSample(StatsSample(
(frame_stats.decode_end_time - frame_stats.decode_start_time).ms(), frame_stats.decode_end_time - frame_stats.decode_start_time,
frame_stats.decode_end_time)); frame_stats.decode_end_time));
} }
@ -479,20 +483,20 @@ void DefaultVideoQualityAnalyzerFramesComparator::ProcessComparison(
frame_stats.rendered_time.IsFinite()) { frame_stats.rendered_time.IsFinite()) {
TimeDelta time_between_rendered_frames = TimeDelta time_between_rendered_frames =
frame_stats.rendered_time - frame_stats.prev_frame_rendered_time; frame_stats.rendered_time - frame_stats.prev_frame_rendered_time;
stats->time_between_rendered_frames_ms.AddSample(StatsSample( stats->time_between_rendered_frames_ms.AddSample(
time_between_rendered_frames.ms(), frame_stats.rendered_time)); StatsSample(time_between_rendered_frames, frame_stats.rendered_time));
double average_time_between_rendered_frames_ms = TimeDelta average_time_between_rendered_frames = TimeDelta::Millis(
stats->time_between_rendered_frames_ms.GetAverage(); stats->time_between_rendered_frames_ms.GetAverage());
if (time_between_rendered_frames.ms() > if (time_between_rendered_frames >
std::max(kFreezeThresholdMs + average_time_between_rendered_frames_ms, std::max(kFreezeThreshold + average_time_between_rendered_frames,
3 * average_time_between_rendered_frames_ms)) { 3 * average_time_between_rendered_frames)) {
stats->freeze_time_ms.AddSample(StatsSample( stats->freeze_time_ms.AddSample(StatsSample(
time_between_rendered_frames.ms(), frame_stats.rendered_time)); time_between_rendered_frames, frame_stats.rendered_time));
auto freeze_end_it = auto freeze_end_it =
stream_last_freeze_end_time_.find(comparison.stats_key); stream_last_freeze_end_time_.find(comparison.stats_key);
RTC_DCHECK(freeze_end_it != stream_last_freeze_end_time_.end()); RTC_DCHECK(freeze_end_it != stream_last_freeze_end_time_.end());
stats->time_between_freezes_ms.AddSample(StatsSample( stats->time_between_freezes_ms.AddSample(StatsSample(
(frame_stats.prev_frame_rendered_time - freeze_end_it->second).ms(), frame_stats.prev_frame_rendered_time - freeze_end_it->second,
frame_stats.rendered_time)); frame_stats.rendered_time));
freeze_end_it->second = frame_stats.rendered_time; freeze_end_it->second = frame_stats.rendered_time;
} }

View File

@ -13,11 +13,9 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "api/test/create_frame_generator.h"
#include "api/units/timestamp.h" #include "api/units/timestamp.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/clock.h" #include "system_wrappers/include/clock.h"
#include "system_wrappers/include/sleep.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_cpu_measurer.h" #include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_cpu_measurer.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h" #include "test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h"
@ -55,7 +53,8 @@ FrameStats FrameStatsWith10msDeltaBetweenPhasesAnd10x10Frame(
frame_stats.encoded_time = captured_time + TimeDelta::Millis(20); frame_stats.encoded_time = captured_time + TimeDelta::Millis(20);
frame_stats.received_time = captured_time + TimeDelta::Millis(30); frame_stats.received_time = captured_time + TimeDelta::Millis(30);
frame_stats.decode_start_time = captured_time + TimeDelta::Millis(40); frame_stats.decode_start_time = captured_time + TimeDelta::Millis(40);
frame_stats.decode_end_time = captured_time + TimeDelta::Millis(50); // Decode time is in microseconds.
frame_stats.decode_end_time = captured_time + TimeDelta::Micros(40010);
frame_stats.rendered_time = captured_time + TimeDelta::Millis(60); frame_stats.rendered_time = captured_time + TimeDelta::Millis(60);
frame_stats.used_encoder = Vp8CodecForOneFrame(1, frame_stats.encoded_time); frame_stats.used_encoder = Vp8CodecForOneFrame(1, frame_stats.encoded_time);
frame_stats.used_decoder = frame_stats.used_decoder =
@ -125,7 +124,7 @@ TEST(DefaultVideoQualityAnalyzerFramesComparatorTest,
EXPECT_DOUBLE_EQ( EXPECT_DOUBLE_EQ(
GetFirstOrDie(stats.at(stats_key).total_delay_incl_transport_ms), 60.0); GetFirstOrDie(stats.at(stats_key).total_delay_incl_transport_ms), 60.0);
EXPECT_DOUBLE_EQ(GetFirstOrDie(stats.at(stats_key).encode_time_ms), 10.0); EXPECT_DOUBLE_EQ(GetFirstOrDie(stats.at(stats_key).encode_time_ms), 10.0);
EXPECT_DOUBLE_EQ(GetFirstOrDie(stats.at(stats_key).decode_time_ms), 10.0); EXPECT_DOUBLE_EQ(GetFirstOrDie(stats.at(stats_key).decode_time_ms), 0.01);
EXPECT_DOUBLE_EQ(GetFirstOrDie(stats.at(stats_key).receive_to_render_time_ms), EXPECT_DOUBLE_EQ(GetFirstOrDie(stats.at(stats_key).receive_to_render_time_ms),
30.0); 30.0);
EXPECT_DOUBLE_EQ( EXPECT_DOUBLE_EQ(