OLD | NEW |
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 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 # ceil((C - A) / refresh-period) | 237 # ceil((C - A) / refresh-period) |
238 # | 238 # |
239 # (each time the number above changes, we have a "jank"). | 239 # (each time the number above changes, we have a "jank"). |
240 # If this happens a lot during an animation, the animation appears | 240 # If this happens a lot during an animation, the animation appears |
241 # janky, even if it runs at 60 fps in average. | 241 # janky, even if it runs at 60 fps in average. |
242 # | 242 # |
243 # We use the special "SurfaceView" window name because the statistics for | 243 # We use the special "SurfaceView" window name because the statistics for |
244 # the activity's main window are not updated when the main web content is | 244 # the activity's main window are not updated when the main web content is |
245 # composited into a SurfaceView. | 245 # composited into a SurfaceView. |
246 results = self._adb.RunShellCommand( | 246 results = self._adb.RunShellCommand( |
247 'dumpsys SurfaceFlinger --latency SurfaceView', log_result=True) | 247 'dumpsys SurfaceFlinger --latency SurfaceView', |
| 248 log_result=logging.getLogger().isEnabledFor(logging.DEBUG)) |
248 if not len(results): | 249 if not len(results): |
249 return (None, None) | 250 return (None, None) |
250 | 251 |
251 timestamps = [] | 252 timestamps = [] |
252 nanoseconds_per_second = 1e9 | 253 nanoseconds_per_second = 1e9 |
253 refresh_period = long(results[0]) / nanoseconds_per_second | 254 refresh_period = long(results[0]) / nanoseconds_per_second |
254 | 255 |
255 # If a fence associated with a frame is still pending when we query the | 256 # If a fence associated with a frame is still pending when we query the |
256 # latency data, SurfaceFlinger gives the frame a timestamp of INT64_MAX. | 257 # latency data, SurfaceFlinger gives the frame a timestamp of INT64_MAX. |
257 # Since we only care about completed frames, we will ignore any timestamps | 258 # Since we only care about completed frames, we will ignore any timestamps |
(...skipping 30 matching lines...) Expand all Loading... |
288 try: | 289 try: |
289 cur_surface = int(match.group(1), 16) | 290 cur_surface = int(match.group(1), 16) |
290 except Exception: | 291 except Exception: |
291 logging.error('Failed to parse current surface from ' + match.group(1)) | 292 logging.error('Failed to parse current surface from ' + match.group(1)) |
292 else: | 293 else: |
293 logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) | 294 logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) |
294 return { | 295 return { |
295 'page_flip_count': cur_surface, | 296 'page_flip_count': cur_surface, |
296 'timestamp': datetime.datetime.now(), | 297 'timestamp': datetime.datetime.now(), |
297 } | 298 } |
OLD | NEW |