Chromium Code Reviews| Index: content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| index 38079dd70bed3528ba88d0c77f972efa1bb37f80..a305bce4ec06a1be7b80cf5b4e50e5f6f83b4b5d 100644 |
| --- a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| +++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc |
| @@ -73,24 +73,39 @@ void UpdateLatencyCoordinates(const WebInputEvent& event, |
| } |
| // Touch to scroll latency that is mostly under 1 second. |
| -#define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(name, start, end) \ |
| +#define UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY(is_first, name, start, end) \ |
| UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| - name, (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, \ |
| - 100) |
| + base::StringPrintf(name, ""), \ |
|
tdresser
2016/09/08 15:17:25
Do we need this StringPrintf? Couldn't we just pas
|
| + (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, 100); \ |
| + if (is_first) { \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + base::StringPrintf(name, "First"), \ |
| + (end.event_time - start.event_time).InMicroseconds(), 1, 1000000, \ |
| + 100); \ |
| + } |
| // Long scroll latency component that is mostly under 200ms. |
| -#define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(name, start, end) \ |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| - name, \ |
| - (end.event_time - start.event_time).InMicroseconds(), \ |
| - 1000, 200000, 50) |
| +#define UMA_HISTOGRAM_SCROLL_LATENCY_LONG(is_first, name, start, end) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + base::StringPrintf(name, ""), \ |
| + (end.event_time - start.event_time).InMicroseconds(), 1000, 200000, 50); \ |
| + if (is_first) { \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + base::StringPrintf(name, "First"), \ |
| + (end.event_time - start.event_time).InMicroseconds(), 1000, 200000, \ |
| + 50); \ |
| + } |
| // Short scroll latency component that is mostly under 50ms. |
| -#define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(name, start, end) \ |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| - name, \ |
| - (end.event_time - start.event_time).InMicroseconds(), \ |
| - 1, 50000, 50) |
| +#define UMA_HISTOGRAM_SCROLL_LATENCY_SHORT(is_first, name, start, end) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + base::StringPrintf(name, ""), \ |
| + (end.event_time - start.event_time).InMicroseconds(), 1, 50000, 50); \ |
| + if (is_first) { \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| + base::StringPrintf(name, "First"), \ |
| + (end.event_time - start.event_time).InMicroseconds(), 1, 50000, 50); \ |
| + } |
| void ComputeScrollLatencyHistograms( |
| const LatencyInfo::LatencyComponent& gpu_swap_begin_component, |
| @@ -105,28 +120,11 @@ void ComputeScrollLatencyHistograms( |
| DCHECK(!gpu_swap_begin_component.event_time.is_null()); |
| DCHECK(!gpu_swap_end_component.event_time.is_null()); |
| LatencyInfo::LatencyComponent original_component; |
| + bool is_first_scroll = false; |
| if (latency.FindLatency( |
| ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| latency_component_id, &original_component)) { |
| - // This UMA metric tracks the time between the final frame swap for the |
| - // first scroll event in a sequence and the original timestamp of that |
| - // scroll event's underlying touch event. |
| - for (size_t i = 0; i < original_component.event_count; i++) { |
| - UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| - "Event.Latency.TouchToFirstScrollUpdateSwapBegin", |
| - original_component, gpu_swap_begin_component); |
| - } |
| - // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| - // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| - // the experimentation finished (crbug.com/638827). |
| - if (is_running_navigation_hint_task) { |
| - for (size_t i = 0; i < original_component.event_count; i++) { |
| - UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| - "Event.Latency.TouchToFirstScrollUpdateSwapBegin_" |
| - "IsRunningNavigationHintTask", |
| - original_component, gpu_swap_begin_component); |
| - } |
| - } |
| + is_first_scroll = true; |
| } else if (!latency.FindLatency( |
| ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| latency_component_id, &original_component)) { |
| @@ -137,8 +135,8 @@ void ComputeScrollLatencyHistograms( |
| // created to when the scroll gesture results in final frame swap. |
| for (size_t i = 0; i < original_component.event_count; i++) { |
| UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| - "Event.Latency.TouchToScrollUpdateSwapBegin", original_component, |
| - gpu_swap_begin_component); |
| + is_first_scroll, "Event.Latency.TouchTo%sScrollUpdateSwapBegin", |
| + original_component, gpu_swap_begin_component); |
| } |
| // TODO(horo): IsRunningNavigationHintTask UMAs are only for |
| // SpeculativeLaunchServiceWorker experimentation. So remove this UMA when |
| @@ -146,14 +144,13 @@ void ComputeScrollLatencyHistograms( |
| if (is_running_navigation_hint_task) { |
| for (size_t i = 0; i < original_component.event_count; i++) { |
| UMA_HISTOGRAM_TOUCH_TO_SCROLL_LATENCY( |
| - "Event.Latency.TouchToScrollUpdateSwapBegin_" |
| + is_first_scroll, |
| + "Event.Latency.TouchTo%sScrollUpdateSwapBegin_" |
| "IsRunningNavigationHintTask", |
| original_component, gpu_swap_begin_component); |
| } |
| } |
| - // TODO(miletus): Add validation for making sure the following components |
| - // are present and their event times are legit. |
| LatencyInfo::LatencyComponent rendering_scheduled_component; |
| bool rendering_scheduled_on_main = latency.FindLatency( |
| ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, |
| @@ -161,53 +158,60 @@ void ComputeScrollLatencyHistograms( |
| if (!rendering_scheduled_on_main) { |
| if (!latency.FindLatency( |
| - ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, |
| - 0, &rendering_scheduled_component)) |
| + ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, 0, |
| + &rendering_scheduled_component)) { |
| return; |
| + } |
| } |
| if (rendering_scheduled_on_main) { |
| UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| - "Event.Latency.ScrollUpdate.TouchToHandled_Main", |
| + is_first_scroll, "Event.Latency.%sScrollUpdate.TouchToHandled_Main", |
| original_component, rendering_scheduled_component); |
| } else { |
| UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| - "Event.Latency.ScrollUpdate.TouchToHandled_Impl", |
| + is_first_scroll, "Event.Latency.%sScrollUpdate.TouchToHandled_Impl", |
| original_component, rendering_scheduled_component); |
| } |
| LatencyInfo::LatencyComponent renderer_swap_component; |
| - if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, |
| - 0, &renderer_swap_component)) |
| + if (!latency.FindLatency(ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, |
| + &renderer_swap_component)) { |
| return; |
| + } |
| if (rendering_scheduled_on_main) { |
| UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| - "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main", |
| + is_first_scroll, |
| + "Event.Latency.%sScrollUpdate.HandledToRendererSwap_Main", |
|
tdresser
2016/09/08 15:17:25
Passing these format strings around is a bit scary
|
| rendering_scheduled_component, renderer_swap_component); |
| } else { |
| UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| - "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", |
| + is_first_scroll, |
| + "Event.Latency.%sScrollUpdate.HandledToRendererSwap_Impl", |
| rendering_scheduled_component, renderer_swap_component); |
| } |
| LatencyInfo::LatencyComponent browser_received_swap_component; |
| if (!latency.FindLatency( |
| - ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, |
| - 0, &browser_received_swap_component)) |
| + ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, |
| + &browser_received_swap_component)) { |
| return; |
| + } |
| UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
| - "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", |
| + is_first_scroll, |
| + "Event.Latency.%sScrollUpdate.RendererSwapToBrowserNotified", |
| renderer_swap_component, browser_received_swap_component); |
| UMA_HISTOGRAM_SCROLL_LATENCY_LONG( |
| - "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
| + is_first_scroll, |
| + "Event.Latency.%sScrollUpdate.BrowserNotifiedToBeforeGpuSwap", |
| browser_received_swap_component, gpu_swap_begin_component); |
| - UMA_HISTOGRAM_SCROLL_LATENCY_SHORT("Event.Latency.ScrollUpdate.GpuSwap", |
| - gpu_swap_begin_component, |
| - gpu_swap_end_component); |
| + UMA_HISTOGRAM_SCROLL_LATENCY_SHORT( |
| + is_first_scroll, "Event.Latency.%sScrollUpdate.GpuSwap", |
| + gpu_swap_begin_component, gpu_swap_end_component); |
| } |
| // LatencyComponents generated in the renderer must have component IDs |