OLD | NEW |
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_PRESS: |
| 22 return "KeyPress"; |
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 Loading... |
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_PRESS) { |
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 // TODO(mfomitchev): crbug.com/717629: Make RAPPOR or UKM reporting work with | 119 // TODO(mfomitchev): crbug.com/717629: Make RAPPOR or UKM reporting work with |
117 // Mus. | 120 // Mus. |
118 } | 121 } |
119 | 122 |
120 void LatencyTracker::ComputeTouchAndWheelScrollLatencyHistograms( | 123 void LatencyTracker::ComputeEndToEndLatencyHistograms( |
121 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, | 124 const ui::LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
122 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, | 125 const ui::LatencyInfo::LatencyComponent& gpu_swap_end_component, |
123 const ui::LatencyInfo& latency) { | 126 const ui::LatencyInfo& latency) { |
124 DCHECK(!latency.coalesced()); | 127 DCHECK(!latency.coalesced()); |
125 if (latency.coalesced()) | 128 if (latency.coalesced()) |
126 return; | 129 return; |
127 | 130 |
128 LatencyInfo::LatencyComponent original_component; | 131 LatencyInfo::LatencyComponent original_component; |
129 std::string scroll_name = "ScrollUpdate"; | 132 std::string scroll_name = "ScrollUpdate"; |
130 | 133 |
(...skipping 30 matching lines...) Expand all Loading... |
161 // First scroll events are excluded from this metric. | 164 // First scroll events are excluded from this metric. |
162 if (input_modality == "Touch") { | 165 if (input_modality == "Touch") { |
163 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( | 166 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
164 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", | 167 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", |
165 original_component, gpu_swap_begin_component); | 168 original_component, gpu_swap_begin_component); |
166 | 169 |
167 ReportRapporScrollLatency( | 170 ReportRapporScrollLatency( |
168 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", | 171 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", |
169 original_component, gpu_swap_begin_component); | 172 original_component, gpu_swap_begin_component); |
170 } | 173 } |
| 174 } else if (latency.FindLatency(ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, |
| 175 &original_component)) { |
| 176 if (input_modality == "KeyPress") { |
| 177 UMA_HISTOGRAM_INPUT_LATENCY_HIGH_RESOLUTION_MICROSECONDS( |
| 178 "Event.Latency.EndToEnd.KeyPress", original_component, |
| 179 gpu_swap_begin_component); |
| 180 } |
171 } else { | 181 } else { |
172 // No original component found. | 182 // No original component found. |
173 return; | 183 return; |
174 } | 184 } |
175 | 185 |
176 LatencyInfo::LatencyComponent rendering_scheduled_component; | 186 LatencyInfo::LatencyComponent rendering_scheduled_component; |
177 bool rendering_scheduled_on_main = latency.FindLatency( | 187 bool rendering_scheduled_on_main = latency.FindLatency( |
178 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, | 188 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, |
179 &rendering_scheduled_component); | 189 &rendering_scheduled_component); |
180 if (!rendering_scheduled_on_main) { | 190 if (!rendering_scheduled_on_main) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 "Event.Latency." + scroll_name + "." + input_modality + | 225 "Event.Latency." + scroll_name + "." + input_modality + |
216 ".BrowserNotifiedToBeforeGpuSwap2", | 226 ".BrowserNotifiedToBeforeGpuSwap2", |
217 browser_received_swap_component, gpu_swap_begin_component); | 227 browser_received_swap_component, gpu_swap_begin_component); |
218 | 228 |
219 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( | 229 UMA_HISTOGRAM_SCROLL_LATENCY_SHORT_2( |
220 "Event.Latency." + scroll_name + "." + input_modality + ".GpuSwap2", | 230 "Event.Latency." + scroll_name + "." + input_modality + ".GpuSwap2", |
221 gpu_swap_begin_component, gpu_swap_end_component); | 231 gpu_swap_begin_component, gpu_swap_end_component); |
222 } | 232 } |
223 | 233 |
224 } // namespace ui | 234 } // namespace ui |
OLD | NEW |