Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1169)

Unified Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc

Issue 2341413002: New scroll latency metrics added for touch and wheel. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
index f75acf43d27b72b4ef89b946bac3ab5c37f595dc..0075ecbde6c502133c9caa2cb575c354f6893ec3 100644
--- a/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
+++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
@@ -16,37 +16,44 @@ using testing::ElementsAre;
namespace content {
namespace {
-void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker,
- ui::LatencyInfo* latency) {
+void AddFakeComponentsWithTimeStamp(
+ const RenderWidgetHostLatencyTracker& tracker,
+ ui::LatencyInfo* latency,
+ base::TimeTicks time_stamp) {
+ latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT,
+ 0, 0, time_stamp, 1);
latency->AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0, base::TimeTicks::Now(), 1);
+ ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, time_stamp,
+ 1);
latency->AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0,
- base::TimeTicks::Now(), 1);
- latency->AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0,
- base::TimeTicks::Now(), 1);
+ ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, time_stamp, 1);
latency->AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
- tracker.latency_component_id(), 0, base::TimeTicks::Now(), 1);
+ tracker.latency_component_id(), 0, time_stamp, 1);
latency->AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0,
- base::TimeTicks::Now(), 1);
+ ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0, time_stamp, 1);
latency->AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0,
- base::TimeTicks::Now(), 1);
+ time_stamp, 1);
+}
+
+void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker,
+ ui::LatencyInfo* latency) {
+ AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now());
}
-void AddRenderingScheduledComponent(ui::LatencyInfo* latency, bool main) {
+void AddRenderingScheduledComponent(ui::LatencyInfo* latency,
+ bool main,
+ base::TimeTicks time_stamp) {
if (main) {
latency->AddLatencyNumberWithTimestamp(
ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 0,
- base::TimeTicks::Now(), 1);
+ time_stamp, 1);
} else {
- latency->AddLatencyNumberWithTimestamp(
- ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, 0,
- base::TimeTicks::Now(), 1);
+ latency->AddLatencyNumberWithTimestamp(
+ ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, 0,
+ time_stamp, 1);
}
}
@@ -89,18 +96,72 @@ class RenderWidgetHostLatencyTrackerTest : public testing::Test {
RenderWidgetHostLatencyTracker tracker_;
};
-TEST_F(RenderWidgetHostLatencyTrackerTest, TestHistograms) {
- for (bool rendering_on_main : { false, true }) {
+TEST_F(RenderWidgetHostLatencyTrackerTest, WheelTestHistograms) {
+ for (bool rendering_on_main : {false, true}) {
+ for (bool is_running_navigation_hint_task : {false, true}) {
+ ResetHistograms();
+ {
+ auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
+ blink::WebMouseWheelEvent::PhaseChanged);
+ base::TimeTicks now = base::TimeTicks::Now();
+ wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
+ ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
+ AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
+ AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
+ tracker()->OnInputEvent(wheel, &wheel_latency);
+ EXPECT_TRUE(wheel_latency.FindLatency(
+ ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
+ tracker()->latency_component_id(), nullptr));
+ EXPECT_TRUE(wheel_latency.FindLatency(
+ ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
+ EXPECT_EQ(1U, wheel_latency.input_coordinates_size());
+ tracker()->OnInputEventAck(wheel, &wheel_latency,
+ INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ tracker()->OnFrameSwapped(wheel_latency,
+ is_running_navigation_hint_task);
+ EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
+ EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
+
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.Wheel.ToFirstScrollUpdateSwapBegin", 1));
+
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel.ToHandled_Main",
+ rendering_on_main ? 1 : 0));
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel.ToHandled_Impl",
+ rendering_on_main ? 0 : 1));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap_Main",
+ rendering_on_main ? 1 : 0));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap_Impl",
+ rendering_on_main ? 0 : 1));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Wheel.RendererSwapToBrowserNotified",
+ 1));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Wheel.BrowserNotifiedToBeforeGpuSwap",
+ 1));
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel.GpuSwap", 1));
+ }
+ }
+ }
+}
+
+TEST_F(RenderWidgetHostLatencyTrackerTest, TouchTestHistograms) {
+ for (bool rendering_on_main : {false, true}) {
for (bool is_running_navigation_hint_task : {false, true}) {
ResetHistograms();
{
auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen);
- scroll.timeStampSeconds =
- (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
+ base::TimeTicks now = base::TimeTicks::Now();
+ scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
ui::LatencyInfo scroll_latency;
- AddFakeComponents(*tracker(), &scroll_latency);
- AddRenderingScheduledComponent(&scroll_latency, rendering_on_main);
+ AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
+ AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
tracker()->OnInputEvent(scroll, &scroll_latency);
EXPECT_TRUE(scroll_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
@@ -113,31 +174,13 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestHistograms) {
}
{
- auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
- blink::WebMouseWheelEvent::PhaseChanged);
- wheel.timeStampSeconds =
- (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
- ui::LatencyInfo wheel_latency;
- AddFakeComponents(*tracker(), &wheel_latency);
- AddRenderingScheduledComponent(&wheel_latency, rendering_on_main);
- tracker()->OnInputEvent(wheel, &wheel_latency);
- EXPECT_TRUE(wheel_latency.FindLatency(
- ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
- tracker()->latency_component_id(), nullptr));
- EXPECT_TRUE(wheel_latency.FindLatency(
- ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
- EXPECT_EQ(1U, wheel_latency.input_coordinates_size());
- tracker()->OnInputEventAck(wheel, &wheel_latency,
- INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
- }
-
- {
SyntheticWebTouchEvent touch;
touch.PressPoint(0, 0);
touch.PressPoint(1, 1);
- ui::LatencyInfo touch_latency;
- AddFakeComponents(*tracker(), &touch_latency);
- AddRenderingScheduledComponent(&touch_latency, rendering_on_main);
+ ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
+ base::TimeTicks now = base::TimeTicks::Now();
+ AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
+ AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
tracker()->OnInputEvent(touch, &touch_latency);
EXPECT_TRUE(touch_latency.FindLatency(
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
@@ -151,10 +194,9 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestHistograms) {
is_running_navigation_hint_task);
}
- EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1));
- EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1));
+
EXPECT_TRUE(HistogramSizeEq(
"Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1));
EXPECT_TRUE(
@@ -184,6 +226,31 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestHistograms) {
EXPECT_TRUE(HistogramSizeEq(
"Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 1));
EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 1));
+
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.Touch.ToFirstScrollUpdateSwapBegin", 1));
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.Touch.ToScrollUpdateSwapBegin", 1));
+
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.ScrollUpdate.Touch.ToHandled_Main",
+ rendering_on_main ? 1 : 0));
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.ScrollUpdate.Touch.ToHandled_Impl",
+ rendering_on_main ? 0 : 1));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Touch.HandledToRendererSwap_Main",
+ rendering_on_main ? 1 : 0));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Touch.HandledToRendererSwap_Impl",
+ rendering_on_main ? 0 : 1));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Touch.RendererSwapToBrowserNotified", 1));
+ EXPECT_TRUE(HistogramSizeEq(
+ "Event.Latency.ScrollUpdate.Touch.BrowserNotifiedToBeforeGpuSwap",
+ 1));
+ EXPECT_TRUE(
+ HistogramSizeEq("Event.Latency.ScrollUpdate.Touch.GpuSwap", 1));
}
}
}
@@ -195,8 +262,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest,
5.f, -5.f, blink::WebGestureDeviceTouchscreen);
ui::LatencyInfo scroll_latency;
AddFakeComponents(*tracker(), &scroll_latency);
- // Don't include the rendering schedule component, since we're testing the
- // case where rendering isn't scheduled.
+ // Don't include the rendering schedule component, since we're testing
+ // the case where rendering isn't scheduled.
tracker()->OnInputEvent(scroll, &scroll_latency);
tracker()->OnInputEventAck(scroll, &scroll_latency,
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
@@ -233,8 +300,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest,
}
{
- auto mouse_move = SyntheticWebMouseEventBuilder::Build(
- blink::WebMouseEvent::MouseMove);
+ auto mouse_move =
+ SyntheticWebMouseEventBuilder::Build(blink::WebMouseEvent::MouseMove);
ui::LatencyInfo mouse_latency;
AddFakeComponents(*tracker(), &mouse_latency);
tracker()->OnInputEvent(mouse_move, &mouse_latency);
@@ -246,8 +313,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest,
}
{
- auto key_event = SyntheticWebKeyboardEventBuilder::Build(
- blink::WebKeyboardEvent::Char);
+ auto key_event =
+ SyntheticWebKeyboardEventBuilder::Build(blink::WebKeyboardEvent::Char);
ui::LatencyInfo key_latency;
AddFakeComponents(*tracker(), &key_latency);
tracker()->OnInputEvent(key_event, &key_latency);

Powered by Google App Engine
This is Rietveld 408576698