Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: build/android/pylib/perf/surface_stats_collector.py

Issue 333933003: [Android] Switch to DeviceUtils version of RunShellCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10 from pylib import android_commands
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 def _ClearSurfaceFlingerLatencyData(self): 209 def _ClearSurfaceFlingerLatencyData(self):
210 """Clears the SurfaceFlinger latency data. 210 """Clears the SurfaceFlinger latency data.
211 211
212 Returns: 212 Returns:
213 True if SurfaceFlinger latency is supported by the device, otherwise 213 True if SurfaceFlinger latency is supported by the device, otherwise
214 False. 214 False.
215 """ 215 """
216 # The command returns nothing if it is supported, otherwise returns many 216 # The command returns nothing if it is supported, otherwise returns many
217 # lines of result just like 'dumpsys SurfaceFlinger'. 217 # lines of result just like 'dumpsys SurfaceFlinger'.
218 results = self._device.old_interface.RunShellCommand( 218 results = self._device.RunShellCommand(
219 'dumpsys SurfaceFlinger --latency-clear SurfaceView') 219 'dumpsys SurfaceFlinger --latency-clear SurfaceView')
220 return not len(results) 220 return not len(results)
221 221
222 def _GetSurfaceFlingerFrameData(self): 222 def _GetSurfaceFlingerFrameData(self):
223 """Returns collected SurfaceFlinger frame timing data. 223 """Returns collected SurfaceFlinger frame timing data.
224 224
225 Returns: 225 Returns:
226 A tuple containing: 226 A tuple containing:
227 - The display's nominal refresh period in seconds. 227 - The display's nominal refresh period in seconds.
228 - A list of timestamps signifying frame presentation times in seconds. 228 - A list of timestamps signifying frame presentation times in seconds.
(...skipping 22 matching lines...) Expand all
251 # 251 #
252 # ceil((C - A) / refresh-period) 252 # ceil((C - A) / refresh-period)
253 # 253 #
254 # (each time the number above changes, we have a "jank"). 254 # (each time the number above changes, we have a "jank").
255 # If this happens a lot during an animation, the animation appears 255 # If this happens a lot during an animation, the animation appears
256 # janky, even if it runs at 60 fps in average. 256 # janky, even if it runs at 60 fps in average.
257 # 257 #
258 # We use the special "SurfaceView" window name because the statistics for 258 # We use the special "SurfaceView" window name because the statistics for
259 # the activity's main window are not updated when the main web content is 259 # the activity's main window are not updated when the main web content is
260 # composited into a SurfaceView. 260 # composited into a SurfaceView.
261 results = self._device.old_interface.RunShellCommand( 261 results = self._device.RunShellCommand(
262 'dumpsys SurfaceFlinger --latency SurfaceView', 262 'dumpsys SurfaceFlinger --latency SurfaceView')
263 log_result=logging.getLogger().isEnabledFor(logging.DEBUG))
264 if not len(results): 263 if not len(results):
265 return (None, None) 264 return (None, None)
266 265
267 timestamps = [] 266 timestamps = []
268 nanoseconds_per_second = 1e9 267 nanoseconds_per_second = 1e9
269 refresh_period = long(results[0]) / nanoseconds_per_second 268 refresh_period = long(results[0]) / nanoseconds_per_second
270 269
271 # If a fence associated with a frame is still pending when we query the 270 # If a fence associated with a frame is still pending when we query the
272 # latency data, SurfaceFlinger gives the frame a timestamp of INT64_MAX. 271 # latency data, SurfaceFlinger gives the frame a timestamp of INT64_MAX.
273 # Since we only care about completed frames, we will ignore any timestamps 272 # Since we only care about completed frames, we will ignore any timestamps
(...skipping 15 matching lines...) Expand all
289 def _GetSurfaceStatsLegacy(self): 288 def _GetSurfaceStatsLegacy(self):
290 """Legacy method (before JellyBean), returns the current Surface index 289 """Legacy method (before JellyBean), returns the current Surface index
291 and timestamp. 290 and timestamp.
292 291
293 Calculate FPS by measuring the difference of Surface index returned by 292 Calculate FPS by measuring the difference of Surface index returned by
294 SurfaceFlinger in a period of time. 293 SurfaceFlinger in a period of time.
295 294
296 Returns: 295 Returns:
297 Dict of {page_flip_count (or 0 if there was an error), timestamp}. 296 Dict of {page_flip_count (or 0 if there was an error), timestamp}.
298 """ 297 """
299 results = self._device.old_interface.RunShellCommand( 298 results = self._device.RunShellCommand('service call SurfaceFlinger 1013')
300 'service call SurfaceFlinger 1013')
301 assert len(results) == 1 299 assert len(results) == 1
302 match = re.search('^Result: Parcel\((\w+)', results[0]) 300 match = re.search('^Result: Parcel\((\w+)', results[0])
303 cur_surface = 0 301 cur_surface = 0
304 if match: 302 if match:
305 try: 303 try:
306 cur_surface = int(match.group(1), 16) 304 cur_surface = int(match.group(1), 16)
307 except Exception: 305 except Exception:
308 logging.error('Failed to parse current surface from ' + match.group(1)) 306 logging.error('Failed to parse current surface from ' + match.group(1))
309 else: 307 else:
310 logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) 308 logging.warning('Failed to call SurfaceFlinger surface ' + results[0])
311 return { 309 return {
312 'page_flip_count': cur_surface, 310 'page_flip_count': cur_surface,
313 'timestamp': datetime.datetime.now(), 311 'timestamp': datetime.datetime.now(),
314 } 312 }
OLDNEW
« no previous file with comments | « build/android/pylib/perf/perf_control_unittest.py ('k') | build/android/pylib/perf/thermal_throttle.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698