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

Side by Side Diff: tools/perf/metrics/rendering_stats.py

Issue 160683003: Collect touch scroll latency for JS driven scroll (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 from operator import attrgetter 5 from operator import attrgetter
6 6
7 # These are LatencyInfo component names indicating the various components 7 # These are LatencyInfo component names indicating the various components
8 # that the input event has travelled through. 8 # that the input event has travelled through.
9 # This is when the input event first reaches chrome. 9 # This is when the input event first reaches chrome.
10 UI_COMP_NAME = 'INPUT_EVENT_LATENCY_UI_COMPONENT' 10 UI_COMP_NAME = 'INPUT_EVENT_LATENCY_UI_COMPONENT'
11 # This is when the input event was originally created by OS. 11 # This is when the input event was originally created by OS.
12 ORIGINAL_COMP_NAME = 'INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT' 12 ORIGINAL_COMP_NAME = 'INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT'
13 # This is when the input event was sent from browser to renderer. 13 # This is when the input event was sent from browser to renderer.
14 BEGIN_COMP_NAME = 'INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT' 14 BEGIN_COMP_NAME = 'INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT'
15 # This is when the input event has reached swap buffer. 15 # This is when the input event has reached swap buffer.
16 END_COMP_NAME = 'INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT' 16 END_COMP_NAME = 'INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT'
17 17
18 def GetScrollInputLatencyEvents(browser_process, timeline_range): 18 def GetScrollInputLatencyEvents(browser_process, timeline_range):
19 """Get scroll events' LatencyInfo from the browser process's trace buffer 19 """Get scroll events' LatencyInfo from the browser process's trace buffer
20 that are within the timeline_range. 20 that are within the timeline_range.
21 21
22 Scroll events (MouseWheel or GestureScrollUpdate) dump their LatencyInfo 22 Scroll events (MouseWheel, GestureScrollUpdate or JS scroll on TouchMove)
23 into trace buffer as async trace event with name "InputLatency". The trace 23 dump their LatencyInfo into trace buffer as async trace event with name
24 event has a memeber 'step' containing its event type and a memeber 'data' 24 "InputLatency". The trace event has a memeber 'step' containing its event
25 containing its latency history. 25 type and a memeber 'data' containing its latency history.
26 26
27 """ 27 """
28 mouse_wheel_events = [] 28 mouse_wheel_events = []
29 touch_scroll_events = [] 29 touch_scroll_events = []
30 if not browser_process: 30 if not browser_process:
31 return (mouse_wheel_events, touch_scroll_events) 31 return (mouse_wheel_events, touch_scroll_events)
32 for event in browser_process.IterAllAsyncSlicesOfName("InputLatency"): 32 for event in browser_process.IterAllAsyncSlicesOfName("InputLatency"):
33 if event.start >= timeline_range.min and event.end <= timeline_range.max: 33 if event.start >= timeline_range.min and event.end <= timeline_range.max:
34 for ss in event.sub_slices: 34 for ss in event.sub_slices:
35 if 'step' not in ss.args: 35 if 'step' not in ss.args:
36 continue 36 continue
37 if 'data' not in ss.args: 37 if 'data' not in ss.args:
38 continue 38 continue
39 if ss.args['step'] == 'MouseWheel': 39 if ss.args['step'] == 'MouseWheel':
40 mouse_wheel_events.append(ss) 40 mouse_wheel_events.append(ss)
41 elif ss.args['step'] == 'GestureScrollUpdate': 41 elif ss.args['step'] == 'GestureScrollUpdate':
42 touch_scroll_events.append(ss) 42 touch_scroll_events.append(ss)
43 elif ss.args['step'] == 'TouchMove':
44 touch_scroll_events.append(ss)
43 return (mouse_wheel_events, touch_scroll_events) 45 return (mouse_wheel_events, touch_scroll_events)
44 46
45 def ComputeMouseWheelScrollLatency(mouse_wheel_events): 47 def ComputeMouseWheelScrollLatency(mouse_wheel_events):
46 """ Compute the mouse wheel scroll latency. 48 """ Compute the mouse wheel scroll latency.
47 49
48 Mouse wheel scroll latency is the time from when mouse wheel event is sent 50 Mouse wheel scroll latency is the time from when mouse wheel event is sent
49 from browser RWH to renderer (the timestamp of component 51 from browser RWH to renderer (the timestamp of component
50 'INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT') to when the scrolled page is 52 'INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT') to when the scrolled page is
51 buffer swapped (the timestamp of component 53 buffer swapped (the timestamp of component
52 'INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT') 54 'INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT')
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 self.frame_timestamps[-1].append( 193 self.frame_timestamps[-1].append(
192 event.start) 194 event.start)
193 if not first_frame: 195 if not first_frame:
194 self.frame_times[-1].append(round(self.frame_timestamps[-1][-1] - 196 self.frame_times[-1].append(round(self.frame_timestamps[-1][-1] -
195 self.frame_timestamps[-1][-2], 2)) 197 self.frame_timestamps[-1][-2], 2))
196 first_frame = False 198 first_frame = False
197 self.rasterize_times[-1].append(1000.0 * 199 self.rasterize_times[-1].append(1000.0 *
198 event.args['data']['rasterize_time']) 200 event.args['data']['rasterize_time'])
199 self.rasterized_pixel_counts[-1].append( 201 self.rasterized_pixel_counts[-1].append(
200 event.args['data']['rasterized_pixel_count']) 202 event.args['data']['rasterized_pixel_count'])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698