| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  212     # composited into a SurfaceView. |  212     # composited into a SurfaceView. | 
|  213     results = self._adb.RunShellCommand( |  213     results = self._adb.RunShellCommand( | 
|  214         'dumpsys SurfaceFlinger --latency SurfaceView', log_result=True) |  214         'dumpsys SurfaceFlinger --latency SurfaceView', log_result=True) | 
|  215     if not len(results): |  215     if not len(results): | 
|  216       return (None, None) |  216       return (None, None) | 
|  217  |  217  | 
|  218     timestamps = [] |  218     timestamps = [] | 
|  219     nanoseconds_per_second = 1e9 |  219     nanoseconds_per_second = 1e9 | 
|  220     refresh_period = long(results[0]) / nanoseconds_per_second |  220     refresh_period = long(results[0]) / nanoseconds_per_second | 
|  221  |  221  | 
|  222     # SurfaceFlinger sometimes gives an invalid timestamp for the very latest |  222     # If a fence associated with a frame is still pending when we query the | 
|  223     # frame if it is queried while the frame is still being presented. We ignore |  223     # latency data, SurfaceFlinger gives the frame a timestamp of INT64_MAX. | 
|  224     # these timestamps. |  224     # Since we only care about completed frames, we will ignore any timestamps | 
|  225     bad_timestamp = (1 << 63) - 1 |  225     # with this value. | 
 |  226     pending_fence_timestamp = (1 << 63) - 1 | 
|  226  |  227  | 
|  227     for line in results[1:]: |  228     for line in results[1:]: | 
|  228       fields = line.split() |  229       fields = line.split() | 
|  229       if len(fields) != 3: |  230       if len(fields) != 3: | 
|  230         continue |  231         continue | 
|  231       timestamp = long(fields[1]) |  232       timestamp = long(fields[1]) | 
|  232       if timestamp == bad_timestamp: |  233       if timestamp == pending_fence_timestamp: | 
|  233         continue |  234         continue | 
|  234       timestamp /= nanoseconds_per_second |  235       timestamp /= nanoseconds_per_second | 
|  235       timestamps.append(timestamp) |  236       timestamps.append(timestamp) | 
|  236  |  237  | 
|  237     return (refresh_period, timestamps) |  238     return (refresh_period, timestamps) | 
|  238  |  239  | 
|  239   def _GetSurfaceStatsLegacy(self): |  240   def _GetSurfaceStatsLegacy(self): | 
|  240     """Legacy method (before JellyBean), returns the current Surface index |  241     """Legacy method (before JellyBean), returns the current Surface index | 
|  241        and timestamp. |  242        and timestamp. | 
|  242  |  243  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  254       try: |  255       try: | 
|  255         cur_surface = int(match.group(1), 16) |  256         cur_surface = int(match.group(1), 16) | 
|  256       except Exception: |  257       except Exception: | 
|  257         logging.error('Failed to parse current surface from ' + match.group(1)) |  258         logging.error('Failed to parse current surface from ' + match.group(1)) | 
|  258     else: |  259     else: | 
|  259       logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) |  260       logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) | 
|  260     return { |  261     return { | 
|  261         'page_flip_count': cur_surface, |  262         'page_flip_count': cur_surface, | 
|  262         'timestamp': datetime.datetime.now(), |  263         'timestamp': datetime.datetime.now(), | 
|  263     } |  264     } | 
| OLD | NEW |