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

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

Issue 358993003: [Android] Switch to DeviceUtils versions of file functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « build/android/pylib/perf/perf_control_unittest.py ('k') | build/android/pylib/screenshot.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 logging 5 import logging
6 from pylib import android_commands 6 from pylib import android_commands
7 from pylib.device import device_utils 7 from pylib.device import device_utils
8 8
9 9
10 class OmapThrottlingDetector(object): 10 class OmapThrottlingDetector(object):
11 """Class to detect and track thermal throttling on an OMAP 4.""" 11 """Class to detect and track thermal throttling on an OMAP 4."""
12 OMAP_TEMP_FILE = ('/sys/devices/platform/omap/omap_temp_sensor.0/' 12 OMAP_TEMP_FILE = ('/sys/devices/platform/omap/omap_temp_sensor.0/'
13 'temperature') 13 'temperature')
14 14
15 @staticmethod 15 @staticmethod
16 def IsSupported(device): 16 def IsSupported(device):
17 return device.old_interface.FileExistsOnDevice( 17 return device.FileExists(OmapThrottlingDetector.OMAP_TEMP_FILE)
18 OmapThrottlingDetector.OMAP_TEMP_FILE)
19 18
20 def __init__(self, device): 19 def __init__(self, device):
21 self._device = device 20 self._device = device
22 21
23 @staticmethod 22 @staticmethod
24 def BecameThrottled(log_line): 23 def BecameThrottled(log_line):
25 return 'omap_thermal_throttle' in log_line 24 return 'omap_thermal_throttle' in log_line
26 25
27 @staticmethod 26 @staticmethod
28 def BecameUnthrottled(log_line): 27 def BecameUnthrottled(log_line):
29 return 'omap_thermal_unthrottle' in log_line 28 return 'omap_thermal_unthrottle' in log_line
30 29
31 @staticmethod 30 @staticmethod
32 def GetThrottlingTemperature(log_line): 31 def GetThrottlingTemperature(log_line):
33 if 'throttle_delayed_work_fn' in log_line: 32 if 'throttle_delayed_work_fn' in log_line:
34 return float([s for s in log_line.split() if s.isdigit()][0]) / 1000.0 33 return float([s for s in log_line.split() if s.isdigit()][0]) / 1000.0
35 34
36 def GetCurrentTemperature(self): 35 def GetCurrentTemperature(self):
37 tempdata = self._device.old_interface.GetFileContents( 36 tempdata = self._device.ReadFile(OmapThrottlingDetector.OMAP_TEMP_FILE)
38 OmapThrottlingDetector.OMAP_TEMP_FILE)
39 return float(tempdata[0]) / 1000.0 37 return float(tempdata[0]) / 1000.0
40 38
41 39
42 class ExynosThrottlingDetector(object): 40 class ExynosThrottlingDetector(object):
43 """Class to detect and track thermal throttling on an Exynos 5.""" 41 """Class to detect and track thermal throttling on an Exynos 5."""
44 @staticmethod 42 @staticmethod
45 def IsSupported(device): 43 def IsSupported(device):
46 return device.old_interface.FileExistsOnDevice('/sys/bus/exynos5-core') 44 return device.FileExists('/sys/bus/exynos5-core')
47 45
48 def __init__(self, device): 46 def __init__(self, device):
49 pass 47 pass
50 48
51 @staticmethod 49 @staticmethod
52 def BecameThrottled(log_line): 50 def BecameThrottled(log_line):
53 return 'exynos_tmu: Throttling interrupt' in log_line 51 return 'exynos_tmu: Throttling interrupt' in log_line
54 52
55 @staticmethod 53 @staticmethod
56 def BecameUnthrottled(log_line): 54 def BecameUnthrottled(log_line):
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 # Print temperature of battery, to give a system temperature 128 # Print temperature of battery, to give a system temperature
131 dumpsys_log = self._device.RunShellCommand('dumpsys battery') 129 dumpsys_log = self._device.RunShellCommand('dumpsys battery')
132 for line in dumpsys_log: 130 for line in dumpsys_log:
133 if 'temperature' in line: 131 if 'temperature' in line:
134 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0 132 btemp = float([s for s in line.split() if s.isdigit()][0]) / 10.0
135 logging.debug(u'Current battery temperature of %s = %3.1f%sC', 133 logging.debug(u'Current battery temperature of %s = %3.1f%sC',
136 serial_number, btemp, degree_symbol) 134 serial_number, btemp, degree_symbol)
137 135
138 return has_been_throttled 136 return has_been_throttled
139 137
OLDNEW
« no previous file with comments | « build/android/pylib/perf/perf_control_unittest.py ('k') | build/android/pylib/screenshot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698