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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/thermal_throttle.py
diff --git a/build/android/pylib/thermal_throttle.py b/build/android/pylib/thermal_throttle.py
new file mode 100644
index 0000000000000000000000000000000000000000..385a48e7ef5f6a4c63e570e729e0247b5b83451b
--- /dev/null
+++ b/build/android/pylib/thermal_throttle.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+
+class ThermalThrottle(object):
+ """Class to detect and track thermal throttling
+
+ Usage:
+ Wait for IsThrottled() to be False before running test
+ After running test call HasBeenThrottled() to find out if the
+ test run was affected by thermal throttling.
+
+ Currently assumes an OMap device.
+ """
+ def __init__(self, adb):
+ self._adb = adb
+ self._throttled = False
+
+
+ def HasBeenThrottled(self):
+ """ True if there has been any throttling since the last call to
+ HasBeenThrottled or IsThrottled
+ """
+ return self._ReadLog()
+
+ def IsThrottled(self):
+ """True if currently throttled"""
+ self._ReadLog()
+ return self._throttled
+
+ def _ReadLog(self):
+ has_been_throttled = False
+ log = self._adb.RunShellCommand('dmesg -c')
+ for line in log:
+ if 'omap_thermal_throttle' in line:
+ if not self._throttled:
+ logging.warning('>>> Thermally Throttled')
+ self._throttled = True
+ has_been_throttled = True
+ if 'omap_thermal_unthrottle' in line:
+ if self._throttled:
+ logging.warning('>>> Thermally Unthrottled')
+ self._throttled = False
+ has_been_throttled = True
+ return has_been_throttled
« 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