Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/render_widget_host_latency_tracker.h" | 5 #include "content/browser/renderer_host/render_widget_host_latency_tracker.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 10 | 10 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 acked_delta.InMicroseconds(), 1, 1000000, 100); | 129 acked_delta.InMicroseconds(), 1, 1000000, 100); |
| 130 break; | 130 break; |
| 131 default: | 131 default: |
| 132 NOTREACHED(); | 132 NOTREACHED(); |
| 133 break; | 133 break; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 void ComputeScrollLatencyHistograms( | 138 void ComputeScrollLatencyHistograms( |
| 139 const LatencyInfo::LatencyComponent& swap_component, | 139 const LatencyInfo::LatencyComponent& gpu_swap_component, |
| 140 int64 latency_component_id, | 140 int64 latency_component_id, |
| 141 const ui::LatencyInfo& latency) { | 141 const LatencyInfo& latency) { |
| 142 DCHECK(!swap_component.event_time.is_null()); | 142 DCHECK(!gpu_swap_component.event_time.is_null()); |
| 143 LatencyInfo::LatencyComponent first_original_component, original_component; | 143 LatencyInfo::LatencyComponent first_original_component, original_component; |
| 144 if (latency.FindLatency( | 144 if (latency.FindLatency( |
| 145 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 145 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 146 latency_component_id, &first_original_component)) { | 146 latency_component_id, &first_original_component)) { |
| 147 // This UMA metric tracks the time between the final frame swap for the | 147 // This UMA metric tracks the time between the final frame swap for the |
| 148 // first scroll event in a sequence and the original timestamp of that | 148 // first scroll event in a sequence and the original timestamp of that |
| 149 // scroll event's underlying touch event. | 149 // scroll event's underlying touch event. |
| 150 for (size_t i = 0; i < first_original_component.event_count; i++) { | 150 for (size_t i = 0; i < first_original_component.event_count; i++) { |
| 151 UMA_HISTOGRAM_CUSTOM_COUNTS( | 151 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 152 "Event.Latency.TouchToFirstScrollUpdateSwap", | 152 "Event.Latency.TouchToFirstScrollUpdateSwap", |
| 153 (swap_component.event_time - first_original_component.event_time) | 153 (gpu_swap_component.event_time - first_original_component.event_time) |
| 154 .InMicroseconds(), | 154 .InMicroseconds(), |
| 155 1, 1000000, 100); | 155 1, 1000000, 100); |
| 156 } | 156 } |
| 157 original_component = first_original_component; | 157 original_component = first_original_component; |
| 158 } else if (!latency.FindLatency( | 158 } else if (!latency.FindLatency( |
| 159 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 159 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 160 latency_component_id, &original_component)) { | 160 latency_component_id, &original_component)) { |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 | 163 |
| 164 // This UMA metric tracks the time from when the original touch event is | 164 // This UMA metric tracks the time from when the original touch event is |
| 165 // created (averaged if there are multiple) to when the scroll gesture | 165 // created (averaged if there are multiple) to when the scroll gesture |
| 166 // results in final frame swap. | 166 // results in final frame swap. |
| 167 for (size_t i = 0; i < original_component.event_count; i++) { | 167 for (size_t i = 0; i < original_component.event_count; i++) { |
| 168 UMA_HISTOGRAM_CUSTOM_COUNTS( | 168 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 169 "Event.Latency.TouchToScrollUpdateSwap", | 169 "Event.Latency.TouchToScrollUpdateSwap", |
| 170 (swap_component.event_time - original_component.event_time) | 170 (gpu_swap_component.event_time - original_component.event_time) |
| 171 .InMicroseconds(), | 171 .InMicroseconds(), |
| 172 1, 1000000, 100); | 172 1, 1000000, 100); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 // LatencyComponents generated in the renderer must have component IDs | 176 // LatencyComponents generated in the renderer must have component IDs |
| 177 // provided to them by the browser process. This function adds the correct | 177 // provided to them by the browser process. This function adds the correct |
| 178 // component ID where necessary. | 178 // component ID where necessary. |
| 179 void AddLatencyInfoComponentIds(LatencyInfo* latency, | 179 void AddLatencyInfoComponentIds(LatencyInfo* latency, |
| 180 int64 latency_component_id) { | 180 int64 latency_component_id) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 std::vector<LatencyInfo>* latencies) { | 305 std::vector<LatencyInfo>* latencies) { |
| 306 DCHECK(latencies); | 306 DCHECK(latencies); |
| 307 for (LatencyInfo& latency : *latencies) { | 307 for (LatencyInfo& latency : *latencies) { |
| 308 AddLatencyInfoComponentIds(&latency, latency_component_id_); | 308 AddLatencyInfoComponentIds(&latency, latency_component_id_); |
| 309 latency.AddLatencyNumber( | 309 latency.AddLatencyNumber( |
| 310 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); | 310 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 void RenderWidgetHostLatencyTracker::OnFrameSwapped( | 314 void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| 315 const ui::LatencyInfo& latency) { | 315 const LatencyInfo& latency) { |
| 316 LatencyInfo::LatencyComponent swap_component; | 316 LatencyInfo::LatencyComponent gpu_swap_component; |
| 317 if (!latency.FindLatency( | 317 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, |
| 318 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, | 318 &gpu_swap_component)) { |
| 319 &swap_component)) { | |
| 320 return; | 319 return; |
| 321 } | 320 } |
| 322 | 321 |
| 323 LatencyInfo::LatencyComponent tab_switch_component; | 322 LatencyInfo::LatencyComponent tab_switch_component; |
| 324 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, | 323 if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, |
| 325 &tab_switch_component)) { | 324 &tab_switch_component)) { |
| 326 base::TimeDelta delta = | 325 base::TimeDelta delta = |
| 327 swap_component.event_time - tab_switch_component.event_time; | 326 gpu_swap_component.event_time - tab_switch_component.event_time; |
| 328 for (size_t i = 0; i < tab_switch_component.event_count; i++) { | 327 for (size_t i = 0; i < tab_switch_component.event_count; i++) { |
| 329 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); | 328 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); |
| 330 } | 329 } |
| 331 } | 330 } |
| 332 | 331 |
| 333 LatencyInfo::LatencyComponent rwh_component; | 332 LatencyInfo::LatencyComponent rwh_component; |
|
Yufeng Shen (Slow to review)
2015/02/12 21:57:50
nit: this can be removed, and just pass nullptr to
| |
| 334 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 333 if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 335 latency_component_id_, &rwh_component)) { | 334 latency_component_id_, &rwh_component)) { |
| 336 return; | 335 return; |
| 337 } | 336 } |
| 338 | 337 |
| 339 ComputeScrollLatencyHistograms(swap_component, latency_component_id_, | 338 ComputeScrollLatencyHistograms(gpu_swap_component, latency_component_id_, |
| 340 latency); | 339 latency); |
| 341 | 340 |
| 342 ui::LatencyInfo::LatencyComponent gpu_swap_component; | 341 LatencyInfo::LatencyComponent browser_swap_component; |
| 343 if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, | |
| 344 &gpu_swap_component)) { | |
| 345 return; | |
| 346 } | |
| 347 | |
| 348 ui::LatencyInfo::LatencyComponent browser_swap_component; | |
| 349 if (latency.FindLatency( | 342 if (latency.FindLatency( |
| 350 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, | 343 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
| 351 &browser_swap_component)) { | 344 &browser_swap_component)) { |
| 352 base::TimeDelta delta = | 345 base::TimeDelta delta = |
| 353 gpu_swap_component.event_time - browser_swap_component.event_time; | 346 gpu_swap_component.event_time - browser_swap_component.event_time; |
| 354 browser_composite_latency_history_.InsertSample(delta); | 347 browser_composite_latency_history_.InsertSample(delta); |
| 355 } | 348 } |
| 356 } | 349 } |
| 357 | 350 |
| 358 base::TimeDelta | 351 base::TimeDelta |
| 359 RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const { | 352 RenderWidgetHostLatencyTracker::GetEstimatedBrowserCompositeTime() const { |
| 360 // TODO(brianderson): Remove lower bound on estimate once we're sure it won't | 353 // TODO(brianderson): Remove lower bound on estimate once we're sure it won't |
| 361 // cause regressions. | 354 // cause regressions. |
| 362 return std::max( | 355 return std::max( |
| 363 browser_composite_latency_history_.Percentile( | 356 browser_composite_latency_history_.Percentile( |
| 364 kBrowserCompositeLatencyEstimationPercentile) * | 357 kBrowserCompositeLatencyEstimationPercentile) * |
| 365 kBrowserCompositeLatencyEstimationSlack, | 358 kBrowserCompositeLatencyEstimationSlack, |
| 366 base::TimeDelta::FromMicroseconds( | 359 base::TimeDelta::FromMicroseconds( |
| 367 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); | 360 (1.0f * base::Time::kMicrosecondsPerSecond) / (3.0f * 60))); |
| 368 } | 361 } |
| 369 | 362 |
| 370 } // namespace content | 363 } // namespace content |
| OLD | NEW |