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

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: address various issues Created 7 years, 6 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 ui_it = latency_info.GetLatencyComponent(
2575 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0);
2576
2577 LatencyIter rwh_it = latency_info.GetLatencyComponent(
2578 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT,
2579 GetLatencyComponentId());
2580
2581 if (rwh_it == latency_map.end() || ui_it == latency_map.end())
2582 return;
2583
2584 DCHECK(ui_it->second.event_count == 1);
2585 DCHECK(rwh_it->second.event_count == 1);
2586
2587 base::TimeDelta ui_delta =
2588 rwh_it->second.event_time - ui_it->second.event_time;
2589 rendering_stats_.touch_ui_count++;
2590 rendering_stats_.total_touch_ui_latency += ui_delta;
2591 UMA_HISTOGRAM_CUSTOM_COUNTS(
2592 "Event.Latency.Touch.UI",
2593 ui_delta.InMicroseconds(),
2594 0,
2595 20000,
2596 100);
2597
2598 LatencyIter acked_consumed_it = latency_info.GetLatencyComponent(
2599 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT,
2600 INPUT_EVENT_ACK_STATE_CONSUMED);
2601
2602 LatencyIter acked_not_consumed_it = latency_info.GetLatencyComponent(
2603 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT,
2604 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2605
2606 LatencyIter acked_no_consumer_it = latency_info.GetLatencyComponent(
2607 ui::INPUT_EVENT_LATENCY_ACKED_COMPONENT,
2608 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS);
2609
2610 if (acked_consumed_it != latency_map.end()) {
2611 base::TimeDelta acked_delta =
2612 acked_consumed_it->second.event_time - rwh_it->second.event_time;
2613 rendering_stats_.touch_acked_consumed_count++;
2614 rendering_stats_.total_touch_acked_consumed_latency += acked_delta;
Rick Byers 2013/06/26 21:42:10 you could probably make this code more concise by
Yufeng Shen (Slow to review) 2013/06/26 23:02:26 After a second thought, I find I don't have strong
Yufeng Shen (Slow to review) 2013/06/26 23:02:26 After a second thought, I find I have no strong ju
2615 UMA_HISTOGRAM_CUSTOM_COUNTS(
2616 "Event.Latency.Touch.Acked_Consumed",
2617 acked_delta.InMicroseconds(),
2618 0,
2619 100000,
Rick Byers 2013/06/26 21:42:10 100ms might be too short, especially on Android.
Yufeng Shen (Slow to review) 2013/06/26 23:02:26 Done.
2620 100);
2621 } else if (acked_not_consumed_it != latency_map.end()) {
2622 base::TimeDelta acked_delta =
2623 acked_not_consumed_it->second.event_time - rwh_it->second.event_time;
2624 rendering_stats_.touch_acked_not_consumed_count++;
2625 rendering_stats_.total_touch_acked_not_consumed_latency += acked_delta;
2626 UMA_HISTOGRAM_CUSTOM_COUNTS(
2627 "Event.Latency.Touch.Acked_Not_Consumed",
2628 acked_delta.InMicroseconds(),
2629 0,
2630 100000,
2631 100);
2632 } else if (acked_no_consumer_it != latency_map.end()) {
2633 base::TimeDelta acked_delta =
2634 acked_no_consumer_it->second.event_time - rwh_it->second.event_time;
2635 rendering_stats_.touch_acked_no_consumer_count++;
2636 rendering_stats_.total_touch_acked_no_consumer_latency += acked_delta;
2637 UMA_HISTOGRAM_CUSTOM_COUNTS(
2638 "Event.Latency.Touch.Acked_No_Consumer_Exists",
2639 acked_delta.InMicroseconds(),
2640 0,
2641 100000,
2642 100);
2643 }
2644
2645 if (CommandLine::ForCurrentProcess()->HasSwitch(
2646 switches::kEnableGpuBenchmarking))
2647 Send(new ViewMsg_SetBrowserRenderingStats(routing_id_, rendering_stats_));
2648 }
2649
2568 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { 2650 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
2569 ui::LatencyInfo::LatencyMap::const_iterator l = 2651 ui::LatencyInfo::LatencyMap::const_iterator l =
2570 latency_info.latency_components.find(std::make_pair( 2652 latency_info.latency_components.find(std::make_pair(
2571 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId())); 2653 ui::INPUT_EVENT_LATENCY_RWH_COMPONENT, GetLatencyComponentId()));
2572 if (l == latency_info.latency_components.end()) 2654 if (l == latency_info.latency_components.end())
2573 return; 2655 return;
2574 2656
2575 rendering_stats_.input_event_count += l->second.event_count; 2657 rendering_stats_.input_event_count += l->second.event_count;
2576 rendering_stats_.total_input_latency += 2658 rendering_stats_.total_input_latency +=
2577 l->second.event_count * 2659 l->second.event_count *
(...skipping 18 matching lines...) Expand all
2596 int process_id = (b->first.second >> 32) & 0xffffffff; 2678 int process_id = (b->first.second >> 32) & 0xffffffff;
2597 RenderWidgetHost* rwh = 2679 RenderWidgetHost* rwh =
2598 RenderWidgetHost::FromID(process_id, routing_id); 2680 RenderWidgetHost::FromID(process_id, routing_id);
2599 if (!rwh) 2681 if (!rwh)
2600 continue; 2682 continue;
2601 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2683 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2602 } 2684 }
2603 } 2685 }
2604 2686
2605 } // namespace content 2687 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698