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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 17757002: Add UMA/Telemetry stats for touch event latency (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
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/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 if (!should_auto_resize_) 2558 if (!should_auto_resize_)
2559 return; 2559 return;
2560 2560
2561 OnRenderAutoResized(new_size); 2561 OnRenderAutoResized(new_size);
2562 } 2562 }
2563 2563
2564 void RenderWidgetHostImpl::DetachDelegate() { 2564 void RenderWidgetHostImpl::DetachDelegate() {
2565 delegate_ = NULL; 2565 delegate_ = NULL;
2566 } 2566 }
2567 2567
2568 void RenderWidgetHostImpl::ComputeTouchLatency(
2569 const ui::LatencyInfo& latency_info) {
2570 typedef ui::LatencyInfo::LatencyMap::const_iterator LatencyIter;
2571 const ui::LatencyInfo::LatencyMap& latency_map =
2572 latency_info.latency_components;
2573
2574 LatencyIter original_it = latency_map.find(std::make_pair(
Rick Byers 2013/06/26 16:34:55 I think it would be a little cleaner to add a Late
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 Done.
2575 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0));
Rick Byers 2013/06/26 16:34:55 Are we guaranteed to have this (eg. for synthetic
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 Done.
2576
2577 LatencyIter ui_it = latency_map.find(std::make_pair(
jbauman 2013/06/26 08:52:53 Is it guaranteed that there will be at most one IN
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 This should be true. This function, ComputeTouchLa
2578 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0));
2579
2580 LatencyIter rwh_it = latency_map.find(std::make_pair(
2581 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
2582 GetLatencyComponentId()));
2583
2584 LatencyIter acked_consumed_it = latency_map.find(std::make_pair(
2585 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT,
2586 INPUT_EVENT_ACK_STATE_CONSUMED));
2587
2588 LatencyIter acked_not_consumed_it = latency_map.find(std::make_pair(
2589 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT,
2590 INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
2591
2592 LatencyIter acked_no_consumer_it = latency_map.find(std::make_pair(
2593 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT,
2594 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS));
2595
2596 base::TimeDelta system_delta =
2597 ui_it->second.event_time - original_it->second.event_time;
2598 rendering_stats_.touch_system_count++;
2599 rendering_stats_.total_touch_system_latency += system_delta;
2600 UMA_HISTOGRAM_CUSTOM_COUNTS(
2601 "Event.Latency.Touch.System",
jbauman 2013/06/26 08:52:53 This is kind of weird, because we're making a hist
Rick Byers 2013/06/26 16:34:55 Yeah, I'm very worried about relying on these aver
Rick Byers 2013/06/26 16:34:55 Isn't Event.Latency.Touch.System basically the sam
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 removed.
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 As comment above, there is no coalesce or latency
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 I think it is already taking the alternative appro
Rick Byers 2013/06/26 21:42:10 Ah, sorry - perfect, thanks!
2602 system_delta.InMicroseconds(),
2603 0,
2604 20000,
2605 100);
2606
2607 base::TimeDelta ui_delta =
2608 rwh_it->second.event_time - ui_it->second.event_time;
2609 rendering_stats_.touch_ui_count++;
2610 rendering_stats_.total_touch_ui_latency += ui_delta;
2611 UMA_HISTOGRAM_CUSTOM_COUNTS(
Rick Byers 2013/06/26 16:34:55 It would be cleaner to use a common macro for all
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 As the reviewer for his CL points out that there i
2612 "Event.Latency.Touch.UI",
2613 ui_delta.InMicroseconds(),
2614 0,
2615 20000,
2616 100);
2617
2618 if (acked_consumed_it != latency_map.end()) {
2619 base::TimeDelta acked_delta =
2620 acked_consumed_it->second.event_time - rwh_it->second.event_time;
2621 rendering_stats_.touch_acked_consumed_count++;
2622 rendering_stats_.total_touch_acked_consumed_latency += acked_delta;
2623 UMA_HISTOGRAM_CUSTOM_COUNTS(
2624 "Event.Latency.Touch.Acked_Consumed",
2625 acked_delta.InMicroseconds(),
2626 0,
2627 100000,
2628 100);
2629 } else if (acked_not_consumed_it != latency_map.end()) {
2630 base::TimeDelta acked_delta =
2631 acked_not_consumed_it->second.event_time - rwh_it->second.event_time;
2632 rendering_stats_.touch_acked_not_consumed_count++;
2633 rendering_stats_.total_touch_acked_not_consumed_latency += acked_delta;
2634 UMA_HISTOGRAM_CUSTOM_COUNTS(
2635 "Event.Latency.Touch.Acked_Not_Consumed",
2636 acked_delta.InMicroseconds(),
2637 0,
2638 100000,
2639 100);
2640 } else if (acked_no_consumer_it != latency_map.end()) {
2641 base::TimeDelta acked_delta =
2642 acked_no_consumer_it->second.event_time - rwh_it->second.event_time;
2643 rendering_stats_.touch_acked_no_consumer_count++;
2644 rendering_stats_.total_touch_acked_no_consumer_latency += acked_delta;
2645 UMA_HISTOGRAM_CUSTOM_COUNTS(
2646 "Event.Latency.Touch.Acked_No_Consumer_Exists",
Rick Byers 2013/06/26 16:34:55 Separating out the metrics into the 3 ACK states i
Yufeng Shen (Slow to review) 2013/06/26 20:44:05 will do
2647 acked_delta.InMicroseconds(),
2648 0,
2649 100000,
2650 100);
2651 }
2652
2653 if (CommandLine::ForCurrentProcess()->HasSwitch(
2654 switches::kEnableGpuBenchmarking))
2655 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_));
2656 }
2657
2568 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { 2658 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
2569 ui::LatencyInfo::LatencyMap::const_iterator l = 2659 ui::LatencyInfo::LatencyMap::const_iterator l =
2570 latency_info.latency_components.find(std::make_pair( 2660 latency_info.latency_components.find(std::make_pair(
2571 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); 2661 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId()));
2572 if (l == latency_info.latency_components.end()) 2662 if (l == latency_info.latency_components.end())
2573 return; 2663 return;
2574 2664
2575 rendering_stats_.input_event_count += l->second.event_count; 2665 rendering_stats_.input_event_count += l->second.event_count;
2576 rendering_stats_.total_input_latency += 2666 rendering_stats_.total_input_latency +=
2577 l->second.event_count * 2667 l->second.event_count *
(...skipping 18 matching lines...) Expand all
2596 int process_id = (b->first.second >> 32) & 0xffffffff; 2686 int process_id = (b->first.second >> 32) & 0xffffffff;
2597 RenderWidgetHost* rwh = 2687 RenderWidgetHost* rwh =
2598 RenderWidgetHost::FromID(process_id, routing_id); 2688 RenderWidgetHost::FromID(process_id, routing_id);
2599 if (!rwh) 2689 if (!rwh)
2600 continue; 2690 continue;
2601 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2691 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2602 } 2692 }
2603 } 2693 }
2604 2694
2605 } // namespace content 2695 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698