OLD | NEW |
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 import Queue | 5 import Queue |
6 import datetime | 6 import datetime |
7 import logging | 7 import logging |
8 import re | 8 import re |
9 import threading | 9 import threading |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 def SampleResults(self): | 65 def SampleResults(self): |
66 self._StorePerfResults() | 66 self._StorePerfResults() |
67 results = self.GetResults() | 67 results = self.GetResults() |
68 self._results = [] | 68 self._results = [] |
69 return results | 69 return results |
70 | 70 |
71 def GetResults(self): | 71 def GetResults(self): |
72 return self._results or self._GetEmptyResults() | 72 return self._results or self._GetEmptyResults() |
73 | 73 |
74 @staticmethod | 74 def _GetEmptyResults(self): |
75 def _GetEmptyResults(): | |
76 return [ | 75 return [ |
77 SurfaceStatsCollector.Result('refresh_period', None, 'seconds'), | 76 SurfaceStatsCollector.Result('refresh_period', None, 'seconds'), |
78 SurfaceStatsCollector.Result('jank_count', None, 'janks'), | 77 SurfaceStatsCollector.Result('jank_count', None, 'janks'), |
79 SurfaceStatsCollector.Result('max_frame_delay', None, 'vsyncs'), | 78 SurfaceStatsCollector.Result('max_frame_delay', None, 'vsyncs'), |
80 SurfaceStatsCollector.Result('frame_lengths', None, 'vsyncs'), | 79 SurfaceStatsCollector.Result('frame_lengths', None, 'vsyncs'), |
81 SurfaceStatsCollector.Result('avg_surface_fps', None, 'fps') | 80 SurfaceStatsCollector.Result('avg_surface_fps', None, 'fps') |
82 ] | 81 ] |
83 | 82 |
84 @staticmethod | 83 @staticmethod |
85 def _GetNormalizedDeltas(data, refresh_period, min_normalized_delta=None): | 84 def _GetNormalizedDeltas(data, refresh_period, min_normalized_delta=None): |
(...skipping 10 matching lines...) Expand all Loading... |
96 seconds = timestamps[-1] - timestamps[0] | 95 seconds = timestamps[-1] - timestamps[0] |
97 | 96 |
98 frame_lengths, normalized_frame_lengths = \ | 97 frame_lengths, normalized_frame_lengths = \ |
99 SurfaceStatsCollector._GetNormalizedDeltas( | 98 SurfaceStatsCollector._GetNormalizedDeltas( |
100 timestamps, refresh_period, _MIN_NORMALIZED_FRAME_LENGTH) | 99 timestamps, refresh_period, _MIN_NORMALIZED_FRAME_LENGTH) |
101 if len(frame_lengths) < frame_count - 1: | 100 if len(frame_lengths) < frame_count - 1: |
102 logging.warning('Skipping frame lengths that are too short.') | 101 logging.warning('Skipping frame lengths that are too short.') |
103 frame_count = len(frame_lengths) + 1 | 102 frame_count = len(frame_lengths) + 1 |
104 if len(frame_lengths) == 0: | 103 if len(frame_lengths) == 0: |
105 raise Exception('No valid frames lengths found.') | 104 raise Exception('No valid frames lengths found.') |
106 _length_changes, normalized_changes = \ | 105 length_changes, normalized_changes = \ |
107 SurfaceStatsCollector._GetNormalizedDeltas( | 106 SurfaceStatsCollector._GetNormalizedDeltas( |
108 frame_lengths, refresh_period) | 107 frame_lengths, refresh_period) |
109 jankiness = [max(0, round(change)) for change in normalized_changes] | 108 jankiness = [max(0, round(change)) for change in normalized_changes] |
110 pause_threshold = 20 | 109 pause_threshold = 20 |
111 jank_count = sum(1 for change in jankiness | 110 jank_count = sum(1 for change in jankiness |
112 if change > 0 and change < pause_threshold) | 111 if change > 0 and change < pause_threshold) |
113 return [ | 112 return [ |
114 SurfaceStatsCollector.Result( | 113 SurfaceStatsCollector.Result( |
115 'avg_surface_fps' + result_suffix, | 114 'avg_surface_fps' + result_suffix, |
116 int(round((frame_count - 1) / seconds)), 'fps'), | 115 int(round((frame_count - 1) / seconds)), 'fps'), |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 try: | 298 try: |
300 cur_surface = int(match.group(1), 16) | 299 cur_surface = int(match.group(1), 16) |
301 except Exception: | 300 except Exception: |
302 logging.error('Failed to parse current surface from ' + match.group(1)) | 301 logging.error('Failed to parse current surface from ' + match.group(1)) |
303 else: | 302 else: |
304 logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) | 303 logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) |
305 return { | 304 return { |
306 'page_flip_count': cur_surface, | 305 'page_flip_count': cur_surface, |
307 'timestamp': datetime.datetime.now(), | 306 'timestamp': datetime.datetime.now(), |
308 } | 307 } |
OLD | NEW |