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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 CASE_TYPE(TouchCancel); 132 CASE_TYPE(TouchCancel);
133 default: 133 default:
134 // Must include default to let WebKit::WebInputEvent add new event types 134 // Must include default to let WebKit::WebInputEvent add new event types
135 // before they're added here. 135 // before they're added here.
136 DLOG(WARNING) << "Unhandled WebInputEvent type in GetEventName.\n"; 136 DLOG(WARNING) << "Unhandled WebInputEvent type in GetEventName.\n";
137 break; 137 break;
138 } 138 }
139 #undef CASE_TYPE 139 #undef CASE_TYPE
140 return ""; 140 return "";
141 } 141 }
142
143 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
144 const ui::LatencyInfo& latency_info,
145 WebInputEvent::Type event_type) {
146 ui::LatencyInfo::LatencyComponent dispatch_component;
147 ui::LatencyInfo::LatencyComponent receive_component;
148 if (latency_info.FindLatency(
149 ui::INPUT_EVENT_LATENCY_SENT_FROM_IMPL_THREAD_COMPONENT,
150 routing_id, &dispatch_component) &&
151 latency_info.FindLatency(
152 ui::INPUT_EVENT_LATENCY_RECEIVED_ON_MAIN_THREAD_COMPONENT,
153 routing_id, &receive_component)) {
154 base::TimeDelta delta = receive_component.event_time -
155 dispatch_component.event_time;
156 switch (event_type) {
157 case WebInputEvent::GestureScrollBegin:
158 case WebInputEvent::GestureScrollUpdate:
159 case WebInputEvent::GestureScrollUpdateWithoutPropagation:
160 UMA_HISTOGRAM_TIMES(
161 "Event.Latency.ImplThreadToRendererThread.GestureScroll", delta);
162 break;
163 case WebInputEvent::TouchStart:
164 case WebInputEvent::TouchMove:
165 UMA_HISTOGRAM_TIMES(
166 "Event.Latency.ImplThreadToRendererThread.Touch", delta);
167 break;
168 default:
169 break;
170 }
171 }
172 }
173
174 void UpdateRenderingStatsForAverageImplThreadLatency(
175 int routing_id,
176 const ui::LatencyInfo& latency_info,
177 cc::RenderingStats& stats) {
178 ui::LatencyInfo::LatencyComponent dispatch_component;
179 ui::LatencyInfo::LatencyComponent receive_component;
180 if (latency_info.FindLatency(
181 ui::INPUT_EVENT_LATENCY_SENT_FROM_IMPL_THREAD_COMPONENT,
182 routing_id, &dispatch_component) &&
183 latency_info.FindLatency(
184 ui::INPUT_EVENT_LATENCY_RECEIVED_ON_MAIN_THREAD_COMPONENT,
185 routing_id, &receive_component)) {
186 stats.total_impl_thread_to_main_thread_time +=
187 (receive_component.event_time - dispatch_component.event_time);
188 stats.total_impl_thread_to_main_thread_count++;
189 }
190 }
191
142 } 192 }
143 namespace content { 193 namespace content {
144 194
145 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, 195 RenderWidget::RenderWidget(WebKit::WebPopupType popup_type,
146 const WebKit::WebScreenInfo& screen_info, 196 const WebKit::WebScreenInfo& screen_info,
147 bool swapped_out) 197 bool swapped_out)
148 : routing_id_(MSG_ROUTING_NONE), 198 : routing_id_(MSG_ROUTING_NONE),
149 surface_id_(0), 199 surface_id_(0),
150 webwidget_(NULL), 200 webwidget_(NULL),
151 opener_id_(MSG_ROUTING_NONE), 201 opener_id_(MSG_ROUTING_NONE),
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 781 }
732 782
733 const char* const event_name = GetEventName(input_event->type); 783 const char* const event_name = GetEventName(input_event->type);
734 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", 784 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent",
735 "event", event_name); 785 "event", event_name);
736 786
737 if (compositor_) 787 if (compositor_)
738 compositor_->SetLatencyInfo(latency_info); 788 compositor_->SetLatencyInfo(latency_info);
739 else 789 else
740 latency_info_.MergeWith(latency_info); 790 latency_info_.MergeWith(latency_info);
791 SendToImplThreadLatencyUma(routing_id(), latency_info, input_event->type);
792 UpdateRenderingStatsForAverageImplThreadLatency(routing_id(), latency_info,
793 software_stats_);
741 794
742 base::TimeDelta now = base::TimeDelta::FromInternalValue( 795 base::TimeDelta now = base::TimeDelta::FromInternalValue(
743 base::TimeTicks::Now().ToInternalValue()); 796 base::TimeTicks::Now().ToInternalValue());
744 797
745 int64 delta = static_cast<int64>( 798 int64 delta = static_cast<int64>(
746 (now.InSecondsF() - input_event->timeStampSeconds) * 799 (now.InSecondsF() - input_event->timeStampSeconds) *
747 base::Time::kMicrosecondsPerSecond); 800 base::Time::kMicrosecondsPerSecond);
748 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Renderer", delta, 0, 1000000, 100); 801 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Renderer", delta, 0, 1000000, 100);
749 base::HistogramBase* counter_for_type = 802 base::HistogramBase* counter_for_type =
750 base::Histogram::FactoryGet( 803 base::Histogram::FactoryGet(
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 compositor_->GetRenderingStats(&stats.rendering_stats); 2379 compositor_->GetRenderingStats(&stats.rendering_stats);
2327 2380
2328 stats.rendering_stats.animation_frame_count += 2381 stats.rendering_stats.animation_frame_count +=
2329 software_stats_.animation_frame_count; 2382 software_stats_.animation_frame_count;
2330 stats.rendering_stats.screen_frame_count += 2383 stats.rendering_stats.screen_frame_count +=
2331 software_stats_.screen_frame_count; 2384 software_stats_.screen_frame_count;
2332 stats.rendering_stats.total_paint_time += 2385 stats.rendering_stats.total_paint_time +=
2333 software_stats_.total_paint_time; 2386 software_stats_.total_paint_time;
2334 stats.rendering_stats.total_pixels_painted += 2387 stats.rendering_stats.total_pixels_painted +=
2335 software_stats_.total_pixels_painted; 2388 software_stats_.total_pixels_painted;
2389 stats.rendering_stats.total_impl_thread_to_main_thread_count +=
2390 software_stats_.total_impl_thread_to_main_thread_count;
2391 stats.rendering_stats.total_impl_thread_to_main_thread_time +=
2392 software_stats_.total_impl_thread_to_main_thread_time;
2336 } 2393 }
2337 2394
2338 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { 2395 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
2339 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 2396 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
2340 if (!gpu_channel) 2397 if (!gpu_channel)
2341 return false; 2398 return false;
2342 2399
2343 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); 2400 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats);
2344 } 2401 }
2345 2402
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 2465
2409 if (!context->InitializeWithDefaultBufferSizes( 2466 if (!context->InitializeWithDefaultBufferSizes(
2410 attributes, 2467 attributes,
2411 false /* bind generates resources */, 2468 false /* bind generates resources */,
2412 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2469 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2413 return NULL; 2470 return NULL;
2414 return context.release(); 2471 return context.release();
2415 } 2472 }
2416 2473
2417 } // namespace content 2474 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698