Commit 7a21d87d authored by Hongbo Song's avatar Hongbo Song Committed by Commit Bot

Add input delay UKM.


This CL is to record input delay UKM which is defined as the duration
between the hardware timestamp and the start of event processing on the
main thread for the meaningful input.

UKM Privacy Review:
https://docs.google.com/document/d/1VQvmb3x7uGMmt2JvKt3_4zk1SPWHPB3yJSiyec7hY20

Bug: 1042004
Change-Id: I69eb91955f116e1f90b9b72a7d3dd13b449fa4ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008436Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarBryan McQuade <bmcquade@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Hongbo Song <hbsong@google.com>
Cr-Commit-Position: refs/heads/master@{#736527}
parent 6a69b5d0
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "third_party/blink/renderer/core/loader/interactive_detector.h" #include "third_party/blink/renderer/core/loader/interactive_detector.h"
#include "base/time/default_tick_clock.h" #include "base/time/default_tick_clock.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
...@@ -228,6 +230,13 @@ void InteractiveDetector::HandleForInputDelay( ...@@ -228,6 +230,13 @@ void InteractiveDetector::HandleForInputDelay(
input_delay_metrics_changed = true; input_delay_metrics_changed = true;
} }
// Record input delay UKM.
ukm::SourceId source_id = GetSupplementable()->UkmSourceID();
DCHECK_NE(source_id, ukm::kInvalidSourceId);
ukm::builders::InputEvent(source_id)
.SetInteractiveTiming_InputDelay(delay.InMilliseconds())
.Record(ukm::UkmRecorder::Get());
UMA_HISTOGRAM_CUSTOM_TIMES(kHistogramInputDelay, delay, UMA_HISTOGRAM_CUSTOM_TIMES(kHistogramInputDelay, delay,
base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMilliseconds(1),
base::TimeDelta::FromSeconds(60), 50); base::TimeDelta::FromSeconds(60), 50);
......
// Copyright 2017 The Chromium Authors. All rights reserved. // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/renderer/core/loader/interactive_detector.h" #include "third_party/blink/renderer/core/loader/interactive_detector.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/paint/first_meaningful_paint_detector.h" #include "third_party/blink/renderer/core/paint/first_meaningful_paint_detector.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h" #include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/core/testing/page_test_base.h"
...@@ -16,6 +19,8 @@ ...@@ -16,6 +19,8 @@
namespace blink { namespace blink {
using InputEvent = ukm::builders::InputEvent;
class NetworkActivityCheckerForTest class NetworkActivityCheckerForTest
: public InteractiveDetector::NetworkActivityChecker { : public InteractiveDetector::NetworkActivityChecker {
public: public:
...@@ -598,4 +603,23 @@ TEST_F(InteractiveDetectorTest, LongTaskAfterTTIDoesNothing) { ...@@ -598,4 +603,23 @@ TEST_F(InteractiveDetectorTest, LongTaskAfterTTIDoesNothing) {
EXPECT_EQ(GetDetector()->GetInteractiveTime(), long_task_1_end_time); EXPECT_EQ(GetDetector()->GetInteractiveTime(), long_task_1_end_time);
} }
TEST_F(InteractiveDetectorTest, RecordInputDelayUKM) {
ukm::TestAutoSetUkmRecorder test_ukm_recorder;
base::TimeDelta delay = base::TimeDelta::FromMilliseconds(10);
Event event;
event.SetTrusted(true);
event.SetType(event_type_names::kClick);
base::TimeTicks processing_start = Now() + delay;
base::TimeTicks event_platform_timestamp = Now();
GetDetector()->HandleForInputDelay(event, event_platform_timestamp,
processing_start);
auto entries = test_ukm_recorder.GetEntriesByName(InputEvent::kEntryName);
EXPECT_EQ(1ul, entries.size());
auto* entry = entries[0];
test_ukm_recorder.ExpectEntryMetric(
entry, InputEvent::kInteractiveTiming_InputDelayName,
delay.InMilliseconds());
}
} // namespace blink } // namespace blink
...@@ -4141,6 +4141,23 @@ be describing additional metrics about the same event. ...@@ -4141,6 +4141,23 @@ be describing additional metrics about the same event.
</metric> </metric>
</event> </event>
<event name="InputEvent">
<owner>hbsong@chromium.org</owner>
<summary>
Metrics associated with user input events. This event is recorded in Blink
and may not be recorded for the same page visits as events like PageLoad.
Consumers of this event's metrics should be aware of this when making
comparisons between InputEvent metrics and PageLoad metrics.
</summary>
<metric name="InteractiveTiming.InputDelay">
<summary>
Measures Input Delay, the duration between the hardware timestamp and the
start of event processing on the main thread for the meaningful input. In
ms. (go/FirstInputDelay)
</summary>
</metric>
</event>
<event name="Intervention.DocumentWrite.ScriptBlock" singular="True"> <event name="Intervention.DocumentWrite.ScriptBlock" singular="True">
<owner>bmcquade@chromium.org</owner> <owner>bmcquade@chromium.org</owner>
<summary> <summary>
......
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