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

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

Issue 11352004: Add a class for management of thermal throttling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more code review fix Created 8 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import logging
6
7 class ThermalThrottle(object):
8 """Class to detect and track thermal throttling
9
10 Usage:
11 Wait for IsThrottled() to be False before running test
12 After running test call HasBeenThrottled() to find out if the
13 test run was affected by thermal throttling.
14
15 Currently assumes an OMap device.
16 """
17 def __init__(self, adb):
18 self._adb = adb
19 self._throttled = False
20
21
22 def HasBeenThrottled(self):
23 """ True if there has been any throttling since the last call to
24 HasBeenThrottled or IsThrottled
25 """
26 return self._ReadLog()
27
28 def IsThrottled(self):
29 """True if currently throttled"""
30 self._ReadLog()
31 return self._throttled
32
33 def _ReadLog(self):
34 has_been_throttled = False
35 log = self._adb.RunShellCommand('dmesg -c')
36 for line in log:
37 if 'omap_thermal_throttle' in line:
38 if not self._throttled:
39 logging.warning('>>> Thermally Throttled')
40 self._throttled = True
41 has_been_throttled = True
42 if 'omap_thermal_unthrottle' in line:
43 if self._throttled:
44 logging.warning('>>> Thermally Unthrottled')
45 self._throttled = False
46 has_been_throttled = True
47 return has_been_throttled
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698