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

Unified Diff: content/renderer/render_widget.cc

Issue 16213002: Add telemetry to track the time an event spent waiting for the main thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor fixes Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index bb06cfe956eaafc0f7e210d0a5f394ea25c9ea6a..b67e469cb52e1f1fd4b016afbfeea6ae3affe226 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -139,6 +139,56 @@ const char* GetEventName(WebInputEvent::Type type) {
#undef CASE_TYPE
return "";
}
+
+void SendToImplThreadLatencyUma(int routing_id,
nduca 2013/07/08 20:58:32 see you're just using the latency info struct but
varunjain 2013/07/10 19:32:37 Hi Nat, while I am looking into how to plumb the l
+ const ui::LatencyInfo& latency_info,
+ WebInputEvent::Type event_type) {
+ ui::LatencyInfo::LatencyComponent dispatch_component;
+ ui::LatencyInfo::LatencyComponent receive_component;
+ if (latency_info.FindLatency(
+ ui::INPUT_EVENT_LATENCY_SENT_FROM_IMPL_THREAD_COMPONENT,
+ routing_id, &dispatch_component) &&
+ latency_info.FindLatency(
+ ui::INPUT_EVENT_LATENCY_RECEIVED_ON_MAIN_THREAD_COMPONENT,
+ routing_id, &receive_component)) {
+ base::TimeDelta delta = receive_component.event_time -
+ dispatch_component.event_time;
+ switch (event_type) {
+ case WebInputEvent::GestureScrollBegin:
+ case WebInputEvent::GestureScrollUpdate:
+ case WebInputEvent::GestureScrollUpdateWithoutPropagation:
+ UMA_HISTOGRAM_TIMES(
+ "Event.Latency.ImplThreadToRendererThread.GestureScroll", delta);
+ break;
+ case WebInputEvent::TouchStart:
+ case WebInputEvent::TouchMove:
+ UMA_HISTOGRAM_TIMES(
+ "Event.Latency.ImplThreadToRendererThread.Touch", delta);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void UpdateRenderingStatsForAverageImplThreadLatency(
+ int routing_id,
+ const ui::LatencyInfo& latency_info,
+ cc::RenderingStats& stats) {
+ ui::LatencyInfo::LatencyComponent dispatch_component;
+ ui::LatencyInfo::LatencyComponent receive_component;
+ if (latency_info.FindLatency(
+ ui::INPUT_EVENT_LATENCY_SENT_FROM_IMPL_THREAD_COMPONENT,
+ routing_id, &dispatch_component) &&
+ latency_info.FindLatency(
+ ui::INPUT_EVENT_LATENCY_RECEIVED_ON_MAIN_THREAD_COMPONENT,
+ routing_id, &receive_component)) {
+ stats.total_impl_thread_to_main_thread_time +=
+ (receive_component.event_time - dispatch_component.event_time);
+ stats.total_impl_thread_to_main_thread_count++;
+ }
+}
+
}
namespace content {
@@ -738,6 +788,9 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
compositor_->SetLatencyInfo(latency_info);
else
latency_info_.MergeWith(latency_info);
+ SendToImplThreadLatencyUma(routing_id(), latency_info, input_event->type);
+ UpdateRenderingStatsForAverageImplThreadLatency(routing_id(), latency_info,
+ software_stats_);
base::TimeDelta now = base::TimeDelta::FromInternalValue(
base::TimeTicks::Now().ToInternalValue());
@@ -2333,6 +2386,10 @@ void RenderWidget::GetRenderingStats(
software_stats_.total_paint_time;
stats.rendering_stats.total_pixels_painted +=
software_stats_.total_pixels_painted;
+ stats.rendering_stats.total_impl_thread_to_main_thread_count +=
+ software_stats_.total_impl_thread_to_main_thread_count;
+ stats.rendering_stats.total_impl_thread_to_main_thread_time +=
+ software_stats_.total_impl_thread_to_main_thread_time;
}
bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {

Powered by Google App Engine
This is Rietveld 408576698