OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 class GpuRenderingStats(object): | |
6 def __init__(self, smoothness_marker, gesture_marker, rendering_stats_deltas, | |
7 used_gpu_benchmarking): | |
8 """ | |
9 Utility class for extracting rendering statistics from the timeline (or | |
10 other loggin facilities), and providing them in a common format to classes | |
11 that compute benchmark metrics from this data. | |
12 | |
13 Stats can either be numbers, or lists of numbers. Classes that calculate | |
14 metrics from the stats must be able to handle both cases. The length of | |
15 different list stats may vary. | |
16 | |
17 All *_time values are measured in seconds. | |
18 """ | |
19 self.renderer_process = smoothness_marker.start_thread.parent | |
20 self.start = gesture_marker.start | |
21 self.end = self.start + gesture_marker.duration | |
22 | |
23 self.total_time = (self.end - self.start) / 1000.0 | |
24 self.animation_frame_count = [] | |
25 self.screen_frame_count = [] | |
26 self.screen_frame_timestamps = [] | |
27 self.paint_time = [] | |
28 self.record_time = [] | |
29 self.best_record_time = [] | |
30 self.commit_time = [] | |
31 self.commit_count = [] | |
32 self.painted_pixel_count = [] | |
33 self.recorded_pixel_count = [] | |
34 self.image_gathering_count = [] | |
35 self.image_gathering_time = [] | |
36 self.dropped_frame_count = [] | |
37 self.rasterize_time = [] | |
38 self.rasterize_time_for_now_bins_on_pending_tree = [] | |
39 self.best_rasterize_time = [] | |
40 self.rasterized_pixel_count = [] | |
41 self.impl_thread_scroll_count = [] | |
42 self.main_thread_scroll_count = [] | |
43 self.drawn_layer_count = [] | |
44 self.missing_tile_count = [] | |
45 self.deferred_image_decode_count = [] | |
46 self.deferred_image_cache_hit_count = [] | |
47 self.tile_analysis_count = [] | |
48 self.solid_color_tile_analysis_count = [] | |
49 self.deferred_image_decode_time = [] | |
50 self.tile_analysis_time = [] | |
51 self.texture_upload_count = [] | |
52 self.texture_upload_time = [] | |
53 self.input_event_count = [] | |
54 self.input_event_latency = [] | |
55 self.touch_ui_count = [] | |
56 self.touch_ui_latency = [] | |
57 self.touch_acked_count = [] | |
58 self.touch_acked_latency = [] | |
59 self.scroll_update_count = [] | |
60 self.scroll_update_latency = [] | |
61 | |
62 if used_gpu_benchmarking: | |
63 self.initMainThreadStatsFromTimeline() | |
64 self.initImplThreadStatsFromTimeline() | |
65 else: | |
66 self.initFrameCountsFromRenderingStats(rendering_stats_deltas) | |
67 self.initTextureStatsFromRenderingStats(rendering_stats_deltas) | |
68 self.initLatencyStatsFromRenderingStats(rendering_stats_deltas) | |
69 | |
70 def initFrameCountsFromRenderingStats(self, rs): | |
71 self.animation_frame_count = rs.get('numAnimationFrames', 0) | |
72 self.screen_frame_count = rs.get('numFramesSentToScreen', 0) | |
73 self.dropped_frame_count = rs.get('droppedFrameCount', 0) | |
74 | |
75 def initTextureStatsFromRenderingStats(self, rs): | |
76 self.texture_upload_count = rs.get('textureUploadCount', 0) | |
77 self.texture_upload_time = rs.get('totalTextureUploadTimeInSeconds', 0) | |
78 | |
79 def initLatencyStatsFromRenderingStats(self, rs): | |
80 self.input_event_count = rs.get('inputEventCount', 0) | |
81 self.input_event_latency = rs.get('totalInputLatency', 0) | |
82 self.touch_ui_count = rs.get('touchUICount', 0) | |
83 self.touch_ui_latency = rs.get('totalTouchUILatency', 0) | |
84 self.touch_acked_count = rs.get('touchAckedCount', 0) | |
85 self.touch_acked_latency = rs.get('totalTouchAckedLatency', 0) | |
86 self.scroll_update_count = rs.get('scrollUpdateCount', 0) | |
87 self.scroll_update_latency = rs.get('totalScrollUpdateLatency', 0) | |
88 | |
89 def initMainThreadStatsFromTimeline(self): | |
90 for event in self.renderer_process.IterAllSlicesOfName( | |
91 'MainThreadRenderingStats::IssueTraceEvent'): | |
92 if event.start >= self.start and event.end <= self.end: | |
93 if 'data' not in event.args: | |
94 continue | |
95 if event.args['data']['screen_frame_count'] > 1: | |
96 raise ValueError, 'trace contains multi-frame render stats' | |
97 self.animation_frame_count.append( | |
98 event.args['data']['animation_frame_count']) | |
99 self.screen_frame_count.append( | |
100 event.args['data']['screen_frame_count']) | |
101 if event.args['data']['screen_frame_count'] == 1: | |
102 self.screen_frame_timestamps.append( | |
103 event.start) | |
104 self.paint_time.append( | |
105 event.args['data']['paint_time']) | |
106 self.record_time.append( | |
107 event.args['data']['record_time']) | |
108 # TODO(ernstm): Remove this check when CL with best_record_time has | |
109 # been picked up by the reference build. | |
110 if 'best_record_time' in event.args['data']: | |
111 self.best_record_time.append( | |
112 event.args['data']['best_record_time']) | |
113 self.commit_time.append( | |
114 event.args['data']['commit_time']) | |
115 self.commit_count.append( | |
116 event.args['data']['commit_count']) | |
117 self.painted_pixel_count.append( | |
118 event.args['data']['painted_pixel_count']) | |
119 self.recorded_pixel_count.append( | |
120 event.args['data']['recorded_pixel_count']) | |
121 self.image_gathering_count.append( | |
122 event.args['data']['image_gathering_count']) | |
123 self.image_gathering_time.append( | |
124 event.args['data']['image_gathering_time']) | |
125 | |
126 def initImplThreadStatsFromTimeline(self): | |
127 for event in self.renderer_process.IterAllSlicesOfName( | |
128 'ImplThreadRenderingStats::IssueTraceEvent'): | |
129 if event.start >= self.start and event.end <= self.end: | |
130 if 'data' not in event.args: | |
131 continue | |
132 if event.args['data']['screen_frame_count'] > 1: | |
133 raise ValueError, 'trace contains multi-frame render stats' | |
134 self.screen_frame_count.append( | |
135 event.args['data']['screen_frame_count']) | |
136 if event.args['data']['screen_frame_count'] == 1: | |
137 self.screen_frame_timestamps.append( | |
138 event.start) | |
139 self.dropped_frame_count.append( | |
140 event.args['data']['dropped_frame_count']) | |
141 self.rasterize_time.append( | |
142 event.args['data']['rasterize_time']) | |
143 self.rasterize_time_for_now_bins_on_pending_tree.append( | |
144 event.args['data']['rasterize_time_for_now_bins_on_pending_tree']) | |
145 self.best_rasterize_time.append( | |
146 event.args['data']['best_rasterize_time']) | |
147 self.rasterized_pixel_count.append( | |
148 event.args['data']['rasterized_pixel_count']) | |
149 self.impl_thread_scroll_count.append( | |
150 event.args['data']['impl_thread_scroll_count']) | |
151 self.main_thread_scroll_count.append( | |
152 event.args['data']['main_thread_scroll_count']) | |
153 self.drawn_layer_count.append( | |
154 event.args['data']['drawn_layer_count']) | |
155 self.missing_tile_count.append( | |
156 event.args['data']['missing_tile_count']) | |
157 self.deferred_image_decode_count.append( | |
158 event.args['data']['deferred_image_decode_count']) | |
159 self.deferred_image_cache_hit_count.append( | |
160 event.args['data']['deferred_image_cache_hit_count']) | |
161 self.tile_analysis_count.append( | |
162 event.args['data']['tile_analysis_count']) | |
163 self.solid_color_tile_analysis_count.append( | |
164 event.args['data']['solid_color_tile_analysis_count']) | |
165 self.deferred_image_decode_time.append( | |
166 event.args['data']['deferred_image_decode_time']) | |
167 self.tile_analysis_time.append( | |
168 event.args['data']['tile_analysis_time']) | |
OLD | NEW |