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 from pylib import android_commands | |
11 from pylib.device import device_utils | 10 from pylib.device import device_utils |
12 | 11 |
13 | 12 |
14 # Log marker containing SurfaceTexture timestamps. | 13 # Log marker containing SurfaceTexture timestamps. |
15 _SURFACE_TEXTURE_TIMESTAMPS_MESSAGE = 'SurfaceTexture update timestamps' | 14 _SURFACE_TEXTURE_TIMESTAMPS_MESSAGE = 'SurfaceTexture update timestamps' |
16 _SURFACE_TEXTURE_TIMESTAMP_RE = r'\d+' | 15 _SURFACE_TEXTURE_TIMESTAMP_RE = r'\d+' |
17 | 16 |
18 | 17 |
19 class SurfaceStatsCollector(object): | 18 class SurfaceStatsCollector(object): |
20 """Collects surface stats for a SurfaceView from the output of SurfaceFlinger. | 19 """Collects surface stats for a SurfaceView from the output of SurfaceFlinger. |
21 | 20 |
22 Args: | 21 Args: |
23 device: A DeviceUtils instance. | 22 device: A DeviceUtils instance. |
24 """ | 23 """ |
25 | 24 |
26 def __init__(self, device): | 25 def __init__(self, device): |
27 # TODO(jbudorick) Remove once telemetry gets switched over. | |
28 assert not isinstance(device, android_commands.AndroidCommands) | |
29 self._device = device | 26 self._device = device |
30 self._collector_thread = None | 27 self._collector_thread = None |
31 self._surface_before = None | 28 self._surface_before = None |
32 self._get_data_event = None | 29 self._get_data_event = None |
33 self._data_queue = None | 30 self._data_queue = None |
34 self._stop_event = None | 31 self._stop_event = None |
35 self._warn_about_empty_data = True | 32 self._warn_about_empty_data = True |
36 | 33 |
37 def DisableWarningAboutEmptyData(self): | 34 def DisableWarningAboutEmptyData(self): |
38 self._warn_about_empty_data = False | 35 self._warn_about_empty_data = False |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 fields = line.split() | 178 fields = line.split() |
182 if len(fields) != 3: | 179 if len(fields) != 3: |
183 continue | 180 continue |
184 timestamp = long(fields[1]) | 181 timestamp = long(fields[1]) |
185 if timestamp == pending_fence_timestamp: | 182 if timestamp == pending_fence_timestamp: |
186 continue | 183 continue |
187 timestamp /= nanoseconds_per_millisecond | 184 timestamp /= nanoseconds_per_millisecond |
188 timestamps.append(timestamp) | 185 timestamps.append(timestamp) |
189 | 186 |
190 return (refresh_period, timestamps) | 187 return (refresh_period, timestamps) |
OLD | NEW |