Skip to content

Commit

Permalink
Add ScrollBegin.Touch/Wheel Event to UKM
Browse files Browse the repository at this point in the history
Report ScrollBegin.wheel/touch TimeToScrollUpdateSwapBegin
via UKM. And add test for them.

BUG=719605, 728707

Review-Url: https://codereview.chromium.org/2924943004
Cr-Commit-Position: refs/heads/master@{#479496}
  • Loading branch information
EiraGe authored and Commit Bot committed Jun 14, 2017
1 parent e0bcc6b commit 223574a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class RenderWidgetHostLatencyTrackerTest
const char* metric_name) {
const ukm::TestUkmRecorder* ukm_recoder =
test_browser_client_.GetTestUkmRecorder();

size_t actual_event_count = 0;
for (size_t i = 0; i < ukm_recoder->entries_count(); ++i) {
const ukm::mojom::UkmEntry* entry = ukm_recoder->GetEntry(i);
Expand Down Expand Up @@ -226,6 +227,7 @@ class RenderWidgetHostLatencyTrackerTest

TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) {
const GURL url(kUrl);
size_t total_ukm_entry_count = 0;
contents()->NavigateAndCommit(url);
for (bool rendering_on_main : {false, true}) {
ResetHistograms();
Expand All @@ -250,6 +252,10 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) {
INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
tracker()->OnGpuSwapBuffersCompleted(wheel_latency);

// UKM metrics.
total_ukm_entry_count++;
EXPECT_TRUE(AssertUkmReported("Event.ScrollBegin.Wheel",
"TimeToScrollUpdateSwapBegin"));
// Rappor metrics.
EXPECT_TRUE(
RapporSampleAssert("Event.Latency.ScrollUpdate.Touch."
Expand Down Expand Up @@ -316,8 +322,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) {

ukm::TestUkmRecorder* test_ukm_recorder =
test_browser_client_.GetTestUkmRecorder();
EXPECT_EQ(0U, test_ukm_recorder->sources_count());
EXPECT_EQ(0U, test_ukm_recorder->entries_count());
EXPECT_EQ(1U, test_ukm_recorder->sources_count());
EXPECT_EQ(total_ukm_entry_count, test_ukm_recorder->entries_count());
}
}
}
Expand Down Expand Up @@ -398,6 +404,7 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) {
TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
const GURL url(kUrl);
contents()->NavigateAndCommit(url);
size_t total_ukm_entry_count = 0;
for (bool rendering_on_main : {false, true}) {
ResetHistograms();
{
Expand Down Expand Up @@ -443,6 +450,10 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
tracker()->OnGpuSwapBuffersCompleted(touch_latency);
}

// UKM metrics.
total_ukm_entry_count++;
EXPECT_TRUE(AssertUkmReported("Event.ScrollBegin.Touch",
"TimeToScrollUpdateSwapBegin"));
// Rappor metrics.
EXPECT_TRUE(
RapporSampleAssert("Event.Latency.ScrollUpdate.Touch."
Expand Down Expand Up @@ -511,8 +522,8 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {

ukm::TestUkmRecorder* test_ukm_recorder =
test_browser_client_.GetTestUkmRecorder();
EXPECT_EQ(0U, test_ukm_recorder->sources_count());
EXPECT_EQ(0U, test_ukm_recorder->entries_count());
EXPECT_EQ(1U, test_ukm_recorder->sources_count());
EXPECT_EQ(total_ukm_entry_count, test_ukm_recorder->entries_count());
}
}

Expand Down
34 changes: 34 additions & 0 deletions tools/metrics/ukm/ukm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,40 @@ be describing additional metrics about the same event.
</metric>
</event>

<event name="Event.ScrollBegin.Touch">
<owner>nzolghadr@chromium.org</owner>
<summary>
Metrics related to first scroll action caused by the generated ScrollUpdate
gesture event.
</summary>
<metric name="TimeToScrollUpdateSwapBegin">
<summary>
The time in microseconds between initial creation of a touch event and the
start of the frame swap on the GPU service caused by the generated
ScrollUpdate gesture event if that ScrollUpdate is the first such event in
a given scroll gesture event sequence. If no swap was induced by the
event, no recording is made.
</summary>
</metric>
</event>

<event name="Event.ScrollBegin.Wheel">
<owner>nzolghadr@chromium.org</owner>
<summary>
Metrics related to first scroll action caused by the generated ScrollUpdate
gesture event.
</summary>
<metric name="TimeToScrollUpdateSwapBegin">
<summary>
The time in microseconds between the initial creation of a wheel event and
the start of the frame swap on the GPU service caused by the generated
ScrollUpdate gesture event if that ScrollUpdate is the first such event in
a given scroll gesture event sequence. If no swap was induced by the
event, no recording is made.
</summary>
</metric>
</event>

<event name="Media.WatchTime">
<owner>dalecurtis@chromium.org</owner>
<summary>
Expand Down
5 changes: 5 additions & 0 deletions ui/latency/latency_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ void LatencyTracker::ComputeEndToEndLatencyHistograms(
".TimeToScrollUpdateSwapBegin2",
original_component, gpu_swap_begin_component);

ReportUkmScrollLatency("Event.ScrollBegin." + input_modality,
"TimeToScrollUpdateSwapBegin", original_component,
gpu_swap_begin_component);

// TODO(lanwei): Will remove them when M56 is stable, see
// https://crbug.com/669618.
UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS(
Expand All @@ -179,6 +183,7 @@ void LatencyTracker::ComputeEndToEndLatencyHistograms(
ReportRapporScrollLatency(
"Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2",
original_component, gpu_swap_begin_component);

ReportUkmScrollLatency("Event.ScrollUpdate.Touch",
"TimeToScrollUpdateSwapBegin", original_component,
gpu_swap_begin_component);
Expand Down

0 comments on commit 223574a

Please sign in to comment.