Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_latency_tracker.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/render_widget_host_latency_tracker.cc |
| index 07df66014ca774bff338542cc42c710f66e4e507..19830bc2e29f5b8c50b5224bee3f265d463558fb 100644 |
| --- a/content/browser/renderer_host/render_widget_host_latency_tracker.cc |
| +++ b/content/browser/renderer_host/render_widget_host_latency_tracker.cc |
| @@ -135,6 +135,12 @@ void ComputeInputLatencyHistograms(WebInputEvent::Type type, |
| } |
| } |
| +// Touch to scroll latency than is mostly under 1 second. |
| +#define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(name, start, end) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + name, (start.event_time - end.event_time).InMicroseconds(), 1, 1000000, \ |
| + 100) |
|
Yufeng Shen (Slow to review)
2015/04/17 22:06:22
please use (end - start) to make it less confusing
brianderson
2015/04/17 22:21:25
D'oh. Done.
|
| + |
| // Long scroll latency component that is mostly under 200ms. |
| #define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ |
| UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| @@ -150,10 +156,12 @@ void ComputeInputLatencyHistograms(WebInputEvent::Type type, |
| 1, 50000, 50) |
| void ComputeScrollLatencyHistograms( |
| - const LatencyInfo::LatencyComponent& gpu_swap_component, |
| + const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| + const LatencyInfo::LatencyComponent& gpu_swap_end_component, |
| int64 latency_component_id, |
| const LatencyInfo& latency) { |
| - DCHECK(!gpu_swap_component.event_time.is_null()); |
| + DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
| + DCHECK(!gpu_swap_end_component.event_time.is_null()); |
| LatencyInfo::LatencyComponent first_original_component, original_component; |
| if (latency.FindLatency( |
| ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| @@ -162,11 +170,14 @@ void ComputeScrollLatencyHistograms( |
| // first scroll event in a sequence and the original timestamp of that |
| // scroll event's underlying touch event. |
| for (size_t i = 0; i < first_original_component.event_count; i++) { |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Event.Latency.TouchToFirstScrollUpdateSwap", |
| - (gpu_swap_component.event_time - first_original_component.event_time) |
| - .InMicroseconds(), |
| - 1, 1000000, 100); |
| + UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| + "Event.Latency.TouchToFirstScrollUpdateSwapBegin", |
| + gpu_swap_begin_component, first_original_component); |
| + // TODO(brianderson): Remove this version once we have enough overlapping |
| + // data with the metric above. |
| + UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| + "Event.Latency.TouchToFirstScrollUpdateSwap", gpu_swap_end_component, |
| + first_original_component); |
| } |
| original_component = first_original_component; |
| } else if (!latency.FindLatency( |
| @@ -179,11 +190,14 @@ void ComputeScrollLatencyHistograms( |
| // created (averaged if there are multiple) to when the scroll gesture |
| // results in final frame swap. |
| for (size_t i = 0; i < original_component.event_count; i++) { |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Event.Latency.TouchToScrollUpdateSwap", |
| - (gpu_swap_component.event_time - original_component.event_time) |
| - .InMicroseconds(), |
| - 1, 1000000, 100); |
| + UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| + "Event.Latency.TouchToScrollUpdateSwapBegin", gpu_swap_begin_component, |
| + original_component); |
| + // TODO(brianderson): Remove this version once we have enough overlapping |
| + // data with the metric above. |
| + UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| + "Event.Latency.TouchToScrollUpdateSwap", gpu_swap_end_component, |
| + original_component); |
| } |
| // TODO(miletus): Add validation for making sure the following components |
| @@ -237,17 +251,11 @@ void ComputeScrollLatencyHistograms( |
| UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
| - browser_received_swap_component, gpu_swap_component); |
| - |
| - LatencyInfo::LatencyComponent gpu_swap_ack_component; |
| - if (!latency.FindLatency( |
| - ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
| - &gpu_swap_ack_component)) |
| - return; |
| + browser_received_swap_component, gpu_swap_begin_component); |
| UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
| - gpu_swap_component, |
| - gpu_swap_ack_component); |
| + gpu_swap_begin_component, |
| + gpu_swap_end_component); |
| } |
| // LatencyComponents generated in the renderer must have component IDs |
| @@ -403,9 +411,16 @@ void RenderWidgetHostLatencyTracker::OnSwapCompositorFrame( |
| void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| const LatencyInfo& latency) { |
| - LatencyInfo::LatencyComponent gpu_swap_component; |
| + LatencyInfo::LatencyComponent gpu_swap_end_component; |
| + if (!latency.FindLatency( |
| + ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
| + &gpu_swap_end_component)) { |
| + return; |
| + } |
| + |
| + LatencyInfo::LatencyComponent gpu_swap_begin_component; |
| if (!latency.FindLatency(ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, |
| - &gpu_swap_component)) { |
| + &gpu_swap_begin_component)) { |
| return; |
| } |
| @@ -413,7 +428,7 @@ void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| if (latency.FindLatency(ui::TAB_SHOW_COMPONENT, latency_component_id_, |
| &tab_switch_component)) { |
| base::TimeDelta delta = |
| - gpu_swap_component.event_time - tab_switch_component.event_time; |
| + gpu_swap_end_component.event_time - tab_switch_component.event_time; |
| for (size_t i = 0; i < tab_switch_component.event_count; i++) { |
| UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", delta); |
| } |
| @@ -424,7 +439,8 @@ void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| return; |
| } |
| - ComputeScrollLatencyHistograms(gpu_swap_component, latency_component_id_, |
| + ComputeScrollLatencyHistograms(gpu_swap_begin_component, |
| + gpu_swap_end_component, latency_component_id_, |
| latency); |
| LatencyInfo::LatencyComponent browser_swap_component; |
| @@ -432,7 +448,7 @@ void RenderWidgetHostLatencyTracker::OnFrameSwapped( |
| ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
| &browser_swap_component)) { |
| base::TimeDelta delta = |
| - gpu_swap_component.event_time - browser_swap_component.event_time; |
| + gpu_swap_begin_component.event_time - browser_swap_component.event_time; |
| browser_composite_latency_history_.InsertSample(delta); |
| } |
| } |