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

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc

Issue 2596473002: Add more input metrics to Rappor (Closed)
Patch Set: Move the assertion line out of the test function Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 name, \ 94 name, \
95 (end.event_time - start.event_time).InMicroseconds(), \ 95 (end.event_time - start.event_time).InMicroseconds(), \
96 1, 50000, 50) 96 1, 50000, 50)
97 97
98 // Check valid timing for start and end latency components. 98 // Check valid timing for start and end latency components.
99 #define CONFIRM_VALID_TIMING(start, end) \ 99 #define CONFIRM_VALID_TIMING(start, end) \
100 DCHECK(!start.first_event_time.is_null()); \ 100 DCHECK(!start.first_event_time.is_null()); \
101 DCHECK(!end.last_event_time.is_null()); \ 101 DCHECK(!end.last_event_time.is_null()); \
102 DCHECK_GE(end.last_event_time, start.first_event_time); 102 DCHECK_GE(end.last_event_time, start.first_event_time);
103 103
104 // Touch/wheel to scroll latency using Rappor.
105 #define RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY(delegate, name, start, end) \
106 CONFIRM_VALID_TIMING(start, end) \
107 rappor::RapporService* rappor_service = \
108 GetContentClient()->browser()->GetRapporService(); \
109 if (rappor_service && delegate) { \
110 std::unique_ptr<rappor::Sample> sample = \
111 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE); \
112 delegate->AddDomainInfoToRapporSample(sample.get()); \
113 sample->SetUInt64Field( \
114 "Latency", \
115 (end.last_event_time - start.first_event_time).InMicroseconds(), \
116 rappor::NO_NOISE); \
117 rappor_service->RecordSample(name, std::move(sample)); \
118 }
119
104 // Touch/wheel to scroll latency that is mostly under 1 second. 120 // Touch/wheel to scroll latency that is mostly under 1 second.
105 #define UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(name, start, end) \ 121 #define UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(name, start, end) \
106 CONFIRM_VALID_TIMING(start, end) \ 122 CONFIRM_VALID_TIMING(start, end) \
107 base::Histogram::FactoryGet(name, 1, 1000000, 100, \ 123 base::Histogram::FactoryGet(name, 1, 1000000, 100, \
108 base::HistogramBase::kUmaTargetedHistogramFlag) \ 124 base::HistogramBase::kUmaTargetedHistogramFlag) \
109 ->Add((end.last_event_time - start.first_event_time).InMicroseconds()); 125 ->Add((end.last_event_time - start.first_event_time).InMicroseconds());
110 126
111 // Long touch/wheel scroll latency component that is mostly under 200ms. 127 // Long touch/wheel scroll latency component that is mostly under 200ms.
112 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(name, start, end) \ 128 #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG_2(name, start, end) \
113 CONFIRM_VALID_TIMING(start, end) \ 129 CONFIRM_VALID_TIMING(start, end) \
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 257 }
242 258
243 void ComputeTouchAndWheelScrollLatencyHistograms( 259 void ComputeTouchAndWheelScrollLatencyHistograms(
244 RenderWidgetHostDelegate* render_widget_host_delegate, 260 RenderWidgetHostDelegate* render_widget_host_delegate,
245 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, 261 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component,
246 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, 262 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component,
247 int64_t latency_component_id, 263 int64_t latency_component_id,
248 const ui::LatencyInfo& latency, 264 const ui::LatencyInfo& latency,
249 const std::string event_type_name) { 265 const std::string event_type_name) {
250 DCHECK(!latency.coalesced()); 266 DCHECK(!latency.coalesced());
267 DCHECK(event_type_name == "Touch" || event_type_name == "Wheel");
251 if (latency.coalesced()) 268 if (latency.coalesced())
252 return; 269 return;
253 270
254 LatencyInfo::LatencyComponent original_component; 271 LatencyInfo::LatencyComponent original_component;
255 std::string scroll_name = "ScrollUpdate"; 272 std::string scroll_name = "ScrollUpdate";
256 if (latency.FindLatency( 273 if (latency.FindLatency(
257 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 274 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
258 latency_component_id, &original_component)) { 275 latency_component_id, &original_component)) {
259 scroll_name = "ScrollBegin"; 276 scroll_name = "ScrollBegin";
260 // This UMA metric tracks the time between the final frame swap for the 277 // This UMA metric tracks the time between the final frame swap for the
261 // first scroll event in a sequence and the original timestamp of that 278 // first scroll event in a sequence and the original timestamp of that
262 // scroll event's underlying touch/wheel event. 279 // scroll event's underlying touch/wheel event.
263 280
264 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( 281 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
265 "Event.Latency.ScrollBegin." + event_type_name + 282 "Event.Latency.ScrollBegin." + event_type_name +
266 ".TimeToScrollUpdateSwapBegin2", 283 ".TimeToScrollUpdateSwapBegin2",
267 original_component, gpu_swap_begin_component); 284 original_component, gpu_swap_begin_component);
268 285
286 RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY(
287 render_widget_host_delegate,
288 "Event.Latency.ScrollBegin." + event_type_name +
289 ".TimeToScrollUpdateSwapBegin2",
290 original_component, gpu_swap_begin_component);
291
269 // TODO(lanwei): Will remove them when M56 is stable, see 292 // TODO(lanwei): Will remove them when M56 is stable, see
270 // https://crbug.com/669618. 293 // https://crbug.com/669618.
271 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( 294 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
272 "Event.Latency.ScrollUpdate." + event_type_name + 295 "Event.Latency.ScrollUpdate." + event_type_name +
273 ".TimeToFirstScrollUpdateSwapBegin2", 296 ".TimeToFirstScrollUpdateSwapBegin2",
274 original_component, gpu_swap_begin_component); 297 original_component, gpu_swap_begin_component);
275 } else if (latency.FindLatency( 298 } else if (latency.FindLatency(
276 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 299 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
277 latency_component_id, &original_component)) { 300 latency_component_id, &original_component)) {
278 // This UMA metric tracks the time from when the original touch event is 301 // This UMA metric tracks the time from when the original touch event is
279 // created to when the scroll gesture results in final frame swap. 302 // created to when the scroll gesture results in final frame swap.
280 // First scroll events are excluded from this metric. 303 // First scroll events are excluded from this metric.
281 if (event_type_name == "Touch") { 304 if (event_type_name == "Touch") {
282 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY( 305 UMA_HISTOGRAM_TOUCH_WHEEL_TO_SCROLL_LATENCY(
283 "Event.Latency.ScrollUpdate." + event_type_name + 306 "Event.Latency.ScrollUpdate." + event_type_name +
284 ".TimeToScrollUpdateSwapBegin2", 307 ".TimeToScrollUpdateSwapBegin2",
285 original_component, gpu_swap_begin_component); 308 original_component, gpu_swap_begin_component);
286 309
287 rappor::RapporService* rappor_service = 310 RAPPOR_TOUCH_WHEEL_TO_SCROLL_LATENCY(
288 GetContentClient()->browser()->GetRapporService(); 311 render_widget_host_delegate,
289 if (rappor_service && render_widget_host_delegate) { 312 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2",
290 std::unique_ptr<rappor::Sample> sample = 313 original_component, gpu_swap_begin_component);
291 rappor_service->CreateSample(rappor::UMA_RAPPOR_TYPE);
292 render_widget_host_delegate->AddDomainInfoToRapporSample(sample.get());
293 sample->SetUInt64Field("Latency",
294 (gpu_swap_begin_component.last_event_time -
295 original_component.first_event_time)
296 .InMicroseconds(),
297 rappor::NO_NOISE);
298 rappor_service->RecordSample(
299 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2",
300 std::move(sample));
301 }
302 } 314 }
303 } else { 315 } else {
304 // No original component found. 316 // No original component found.
305 return; 317 return;
306 } 318 }
307 319
308 LatencyInfo::LatencyComponent rendering_scheduled_component; 320 LatencyInfo::LatencyComponent rendering_scheduled_component;
309 bool rendering_scheduled_on_main = latency.FindLatency( 321 bool rendering_scheduled_on_main = latency.FindLatency(
310 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 322 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
311 &rendering_scheduled_component); 323 &rendering_scheduled_component);
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 latency, is_running_navigation_hint_task); 761 latency, is_running_navigation_hint_task);
750 } 762 }
751 } 763 }
752 764
753 void RenderWidgetHostLatencyTracker::SetDelegate( 765 void RenderWidgetHostLatencyTracker::SetDelegate(
754 RenderWidgetHostDelegate* delegate) { 766 RenderWidgetHostDelegate* delegate) {
755 render_widget_host_delegate_ = delegate; 767 render_widget_host_delegate_ = delegate;
756 } 768 }
757 769
758 } // namespace content 770 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698