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

Side by Side Diff: ui/latency/latency_tracker.cc

Issue 2756893002: Add Keyboard Latency UMA Metrics. (Closed)
Patch Set: mfomitchev responses, rebase Created 3 years, 7 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 unified diff | Download patch
« ui/events/event.cc ('K') | « ui/latency/latency_tracker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ui/latency/latency_tracker.h" 5 #include "ui/latency/latency_tracker.h"
6 6
7 #include "base/metrics/histogram_functions.h" 7 #include "base/metrics/histogram_functions.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "ui/latency/latency_histogram_macros.h" 9 #include "ui/latency/latency_histogram_macros.h"
10 10
11 namespace ui { 11 namespace ui {
12 namespace { 12 namespace {
13 13
14 std::string LatencySourceEventTypeToInputModalityString( 14 std::string LatencySourceEventTypeToInputModalityString(
15 ui::SourceEventType type) { 15 ui::SourceEventType type) {
16 switch (type) { 16 switch (type) {
17 case ui::SourceEventType::WHEEL: 17 case ui::SourceEventType::WHEEL:
18 return "Wheel"; 18 return "Wheel";
19 case ui::SourceEventType::TOUCH: 19 case ui::SourceEventType::TOUCH:
20 return "Touch"; 20 return "Touch";
21 case ui::SourceEventType::KEY:
22 return "Key";
21 default: 23 default:
22 return ""; 24 return "";
23 } 25 }
24 } 26 }
25 27
26 void ComputeScrollLatencyHistograms( 28 void ComputeScrollLatencyHistograms(
27 const LatencyInfo::LatencyComponent& gpu_swap_begin_component, 29 const LatencyInfo::LatencyComponent& gpu_swap_begin_component,
28 const LatencyInfo::LatencyComponent& gpu_swap_end_component, 30 const LatencyInfo::LatencyComponent& gpu_swap_end_component,
29 const LatencyInfo& latency) { 31 const LatencyInfo& latency) {
30 DCHECK(!latency.coalesced()); 32 DCHECK(!latency.coalesced());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 87 }
86 } 88 }
87 89
88 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 90 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
89 nullptr)) { 91 nullptr)) {
90 return; 92 return;
91 } 93 }
92 94
93 ui::SourceEventType source_event_type = latency.source_event_type(); 95 ui::SourceEventType source_event_type = latency.source_event_type();
94 if (source_event_type == ui::SourceEventType::WHEEL || 96 if (source_event_type == ui::SourceEventType::WHEEL ||
95 source_event_type == ui::SourceEventType::TOUCH) { 97 source_event_type == ui::SourceEventType::TOUCH ||
96 ComputeTouchAndWheelScrollLatencyHistograms( 98 source_event_type == ui::SourceEventType::KEY) {
97 gpu_swap_begin_component, gpu_swap_end_component, latency); 99 ComputeEndToEndLatencyHistograms(gpu_swap_begin_component,
100 gpu_swap_end_component, latency);
98 } 101 }
99 102
100 // Compute the old scroll update latency metrics. They are exclusively 103 // Compute the old scroll update latency metrics. They are exclusively
101 // calculated for touch scrolls, and will be deprecated on M56. 104 // calculated for touch scrolls, and will be deprecated on M56.
102 // (https://crbug.com/649754) 105 // (https://crbug.com/649754)
103 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component; 106 LatencyInfo::LatencyComponent mouse_wheel_scroll_update_component;
104 if (!latency.FindLatency( 107 if (!latency.FindLatency(
105 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, 108 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0,
106 &mouse_wheel_scroll_update_component)) { 109 &mouse_wheel_scroll_update_component)) {
107 ComputeScrollLatencyHistograms(gpu_swap_begin_component, 110 ComputeScrollLatencyHistograms(gpu_swap_begin_component,
108 gpu_swap_end_component, latency); 111 gpu_swap_end_component, latency);
109 } 112 }
110 } 113 }
111 114
112 void LatencyTracker::ReportRapporScrollLatency( 115 void LatencyTracker::ReportRapporScrollLatency(
113 const std::string& name, 116 const std::string& name,
114 const LatencyInfo::LatencyComponent& start_component, 117 const LatencyInfo::LatencyComponent& start_component,
115 const LatencyInfo::LatencyComponent& end_component) {} 118 const LatencyInfo::LatencyComponent& end_component) {}
116 119
117 void LatencyTracker::ComputeTouchAndWheelScrollLatencyHistograms( 120 void LatencyTracker::ComputeEndToEndLatencyHistograms(
118 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, 121 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component,
119 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, 122 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component,
120 const ui::LatencyInfo& latency) { 123 const ui::LatencyInfo& latency) {
121 DCHECK(!latency.coalesced()); 124 DCHECK(!latency.coalesced());
122 if (latency.coalesced()) 125 if (latency.coalesced())
123 return; 126 return;
124 127
125 LatencyInfo::LatencyComponent original_component; 128 LatencyInfo::LatencyComponent original_component;
126 std::string scroll_name = "ScrollUpdate"; 129 std::string scroll_name = "ScrollUpdate";
127 130
(...skipping 30 matching lines...) Expand all
158 // First scroll events are excluded from this metric. 161 // First scroll events are excluded from this metric.
159 if (input_modality == "Touch") { 162 if (input_modality == "Touch") {
160 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( 163 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS(
161 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", 164 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2",
162 original_component, gpu_swap_begin_component); 165 original_component, gpu_swap_begin_component);
163 166
164 ReportRapporScrollLatency( 167 ReportRapporScrollLatency(
165 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", 168 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2",
166 original_component, gpu_swap_begin_component); 169 original_component, gpu_swap_begin_component);
167 } 170 }
171 } else if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0,
172 &original_component)) {
173 if (input_modality == "Key") {
174 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS(
175 "Event.Latency.EndToEnd.Key", original_component,
176 gpu_swap_begin_component);
177 }
168 } else { 178 } else {
169 // No original component found. 179 // No original component found.
170 return; 180 return;
171 } 181 }
172 182
173 LatencyInfo::LatencyComponent rendering_scheduled_component; 183 LatencyInfo::LatencyComponent rendering_scheduled_component;
174 bool rendering_scheduled_on_main = latency.FindLatency( 184 bool rendering_scheduled_on_main = latency.FindLatency(
175 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 185 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0,
176 &rendering_scheduled_component); 186 &rendering_scheduled_component);
177 if (!rendering_scheduled_on_main) { 187 if (!rendering_scheduled_on_main) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 "Event.Latency." + scroll_name + "." + input_modality + 222 "Event.Latency." + scroll_name + "." + input_modality +
213 ".BrowserNotifiedToBeforeGpuSwap2", 223 ".BrowserNotifiedToBeforeGpuSwap2",
214 browser_received_swap_component, gpu_swap_begin_component); 224 browser_received_swap_component, gpu_swap_begin_component);
215 225
216 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( 226 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2(
217 "Event.Latency." + scroll_name + "." + input_modality + ".GpuSwap2", 227 "Event.Latency." + scroll_name + "." + input_modality + ".GpuSwap2",
218 gpu_swap_begin_component, gpu_swap_end_component); 228 gpu_swap_begin_component, gpu_swap_end_component);
219 } 229 }
220 230
221 } // namespace ui 231 } // namespace ui
OLDNEW
« ui/events/event.cc ('K') | « ui/latency/latency_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698