Commit 460ea6f6 authored by behdad's avatar behdad Committed by Chromium LUCI CQ

Use the frame rate to calculate total frames in window

The interval of last frame in sliding window is used to calculate the total expected frames in window.
Test are also updated to reflect this change in calculation of percent dropped frames.

Bug: 1167213
Change-Id: I5dd7e608d35b33af90046867d70bc652cced0366
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2633922Reviewed-by: default avatarJonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Behdad Bakhshinategh <behdadb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844549}
parent ce17e926
......@@ -93,6 +93,9 @@ void DroppedFrameCounter::OnBeginFrame(const viz::BeginFrameArgs& args) {
void DroppedFrameCounter::OnEndFrame(const viz::BeginFrameArgs& args,
bool is_dropped) {
if (!args.interval.is_zero())
total_frames_in_window_ = kSlidingWindowInterval / args.interval;
if (is_dropped) {
if (fcp_received_)
++total_smoothness_dropped_;
......@@ -195,7 +198,8 @@ void DroppedFrameCounter::NotifyFrameResult(const viz::BeginFrameArgs& args,
DCHECK_GE(sliding_window_.size(), dropped_frame_count_in_window_);
double percent_dropped_frame =
(dropped_frame_count_in_window_ * 100.0) / sliding_window_.size();
fmin((dropped_frame_count_in_window_ * 100.0) / total_frames_in_window_,
100.0);
sliding_window_max_percent_dropped_ =
fmax(sliding_window_max_percent_dropped_, percent_dropped_frame);
sliding_window_histogram_.AddPercentDroppedFrame(percent_dropped_frame);
......
......@@ -96,6 +96,7 @@ class CC_EXPORT DroppedFrameCounter {
base::TimeDelta::FromSeconds(1);
std::queue<std::pair<const viz::BeginFrameArgs, bool>> sliding_window_;
uint32_t dropped_frame_count_in_window_ = 0;
double total_frames_in_window_ = 60.0;
SlidingWindowHistogram sliding_window_histogram_;
RingBufferType ring_buffer_;
......
......@@ -283,6 +283,10 @@ class DroppedFrameCounterTest : public testing::Test {
return dropped_frame_counter_.SlidingWindow95PercentilePercentDropped();
}
double GetTotalFramesInWindow() {
return base::TimeDelta::FromSeconds(1) / interval_;
}
void SetInterval(base::TimeDelta interval) { interval_ = interval; }
private:
......@@ -308,7 +312,9 @@ class DroppedFrameCounterTest : public testing::Test {
TEST_F(DroppedFrameCounterTest, SimplePattern1) {
// 2 out of every 3 frames are dropped (In total 80 frames out of 120).
SimulateFrameSequence({true, true, true, false, true, false}, 20);
EXPECT_EQ(MaxPercentDroppedFrame(), 200.0 / 3);
double expected_percent_dropped_frame = (40 / GetTotalFramesInWindow()) * 100;
EXPECT_FLOAT_EQ(MaxPercentDroppedFrame(), expected_percent_dropped_frame);
EXPECT_EQ(PercentDroppedFrame95Percentile(), 67); // all values are in the
// 67th bucket, and as a result 95th percentile is also 67.
}
......@@ -316,7 +322,9 @@ TEST_F(DroppedFrameCounterTest, SimplePattern1) {
TEST_F(DroppedFrameCounterTest, SimplePattern2) {
// 1 out of every 5 frames are dropped (In total 24 frames out of 120).
SimulateFrameSequence({false, false, false, false, true}, 24);
EXPECT_EQ(MaxPercentDroppedFrame(), 20.0);
double expected_percent_dropped_frame = (12 / GetTotalFramesInWindow()) * 100;
EXPECT_FLOAT_EQ(MaxPercentDroppedFrame(), expected_percent_dropped_frame);
EXPECT_EQ(PercentDroppedFrame95Percentile(), 20); // all values are in the
// 20th bucket, and as a result 95th percentile is also 20.
}
......@@ -332,22 +340,28 @@ TEST_F(DroppedFrameCounterTest, IncompleteWindow) {
TEST_F(DroppedFrameCounterTest, MaxPercentDroppedChanges) {
// First 60 frames have 20% dropped.
SimulateFrameSequence({false, false, false, false, true}, 12);
EXPECT_EQ(MaxPercentDroppedFrame(), 20.0);
EXPECT_EQ(PercentDroppedFrame95Percentile(), 20); // There is only one
double expected_percent_dropped_frame1 =
(12 / GetTotalFramesInWindow()) * 100;
EXPECT_EQ(MaxPercentDroppedFrame(), expected_percent_dropped_frame1);
EXPECT_FLOAT_EQ(PercentDroppedFrame95Percentile(), 20); // There is only one
// element in the histogram and that is 20.
// 30 new frames are added that have 18 dropped frames.
// and the 30 frame before that had 6 dropped frames.
// So in total in the window has 24 frames dropped out of 60 frames.
SimulateFrameSequence({false, false, true, true, true}, 6);
EXPECT_EQ(MaxPercentDroppedFrame(), 40.0);
double expected_percent_dropped_frame2 =
(24 / GetTotalFramesInWindow()) * 100;
EXPECT_FLOAT_EQ(MaxPercentDroppedFrame(), expected_percent_dropped_frame2);
// 30 new frames are added that have 24 dropped frames.
// and the 30 frame before that had 18 dropped frames.
// So in total in the window has 42 frames dropped out of 60 frames.
SimulateFrameSequence({false, true, true, true, true}, 6);
EXPECT_EQ(MaxPercentDroppedFrame(), 70.0);
double expected_percent_dropped_frame3 =
(42 / GetTotalFramesInWindow()) * 100;
EXPECT_FLOAT_EQ(MaxPercentDroppedFrame(), expected_percent_dropped_frame3);
// Percent dropped frame of window increases gradually to 70%.
// 1 value exist when we reach 60 frames and 1 value thereafter for each
......@@ -368,7 +382,8 @@ TEST_F(DroppedFrameCounterTest, MaxPercentDroppedWithIdleFrames) {
// So in total, there are 40 frames in the 1 second window with 16 dropped
// frames (40% in total).
EXPECT_EQ(MaxPercentDroppedFrame(), 40.0);
double expected_percent_dropped_frame = (16 / GetTotalFramesInWindow()) * 100;
EXPECT_FLOAT_EQ(MaxPercentDroppedFrame(), expected_percent_dropped_frame);
}
TEST_F(DroppedFrameCounterTest, NoCrashForIntervalLargerThanWindow) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment