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

Side by Side Diff: tools/telemetry/telemetry/android_platform.py

Issue 11428107: Telemetry: extends Platform abstraction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Platform API Created 8 years 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 | Annotate | Revision Log
OLDNEW
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 logging
5 import os 6 import os
6 import sys 7 import sys
7 8
9 from telemetry import platform
10
8 # Get build/android scripts into our path. 11 # Get build/android scripts into our path.
9 sys.path.append( 12 sys.path.append(
10 os.path.abspath( 13 os.path.abspath(
11 os.path.join(os.path.dirname(__file__), 14 os.path.join(os.path.dirname(__file__),
12 '../../../build/android'))) 15 '../../../build/android')))
16
17 from pylib import perf_tests_helper # pylint: disable=F0401
18 from pylib import thermal_throttle # pylint: disable=F0401
19
13 try: 20 try:
14 from pylib import surface_stats_collector # pylint: disable=F0401 21 from pylib import surface_stats_collector # pylint: disable=F0401
15 except Exception: 22 except Exception:
16 surface_stats_collector = None 23 surface_stats_collector = None
17 24
18 25
19 class AndroidPlatform(object): 26 class AndroidPlatform(platform.Platform):
20 def __init__(self, adb, window_package, window_activity): 27 def __init__(self, adb, window_package, window_activity):
21 super(AndroidPlatform, self).__init__() 28 super(AndroidPlatform, self).__init__()
22 self._adb = adb 29 self._adb = adb
23 self._window_package = window_package 30 self._window_package = window_package
24 self._window_activity = window_activity 31 self._window_activity = window_activity
32 self._surface_stats_collector = None
33 self._perf_tests_setup = perf_tests_helper.PerfTestSetup(adb)
34 self._thermal_throttle = None
25 35
26 def GetSurfaceCollector(self, trace_tag): 36 def IsRawDisplayFrameRateSupported(self):
27 return surface_stats_collector.SurfaceStatsCollector( 37 return True
28 self._adb, self._window_package, self._window_activity, trace_tag) 38
39 def StartRawDisplayFrameRate(self, trace_tag):
40 assert not self._surface_stats_collector
41 self._surface_stats_collector = \
42 surface_stats_collector.SurfaceStatsCollector(
43 self._adb, self._window_package, self._window_activity, trace_tag)
44 self._surface_stats_collector.__enter__()
45
46 def GetRawDisplayFrameRate(self):
47 self._surface_stats_collector.__exit__()
48 self._surface_stats_collector = None
49
50 def SetFullPerformanceModeEnabled(self, enabled):
51 if enabled:
52 self._perf_tests_setup.SetUp()
53 else:
54 self._perf_tests_setup.TearDown()
55
56 def CanMonitorThermalThrottling(self):
57 return True
58
59 def StartMonitoringThermalThrottling(self):
60 assert not self._thermal_throttle
61 self._thermal_throttle = thermal_throttle.ThermalThrottle(self._adb)
62 if self._thermal_throttle.IsThrottled():
63 logging.warn('Device is being thermally throttled.')
64
65 def StopMonitoringThermalThrottling(self):
66 has_been_throttled = self._thermal_throttle.HasBeenThrottled()
67 self._thermal_throttle = None
68 if has_been_throttled:
69 logging.warn('Device was thermally throttled during tests.')
70 return True
71 return False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698