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

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

Issue 11352004: Add a class for management of thermal throttling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 re 5 import re
6 import logging
6 7
7 import android_commands 8 import android_commands
8 import math 9 import math
9 10
10 # Valid values of result type. 11 # Valid values of result type.
11 RESULT_TYPES = {'unimportant': 'RESULT ', 12 RESULT_TYPES = {'unimportant': 'RESULT ',
12 'default': '*RESULT ', 13 'default': '*RESULT ',
13 'informational': ''} 14 'informational': ''}
14 15
15 16
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 def TearDown(self): 112 def TearDown(self):
112 """Tears down performance tests.""" 113 """Tears down performance tests."""
113 if self._original_scaling_governor: 114 if self._original_scaling_governor:
114 self._SetScalingGovernorInternal(self._original_scaling_governor) 115 self._SetScalingGovernorInternal(self._original_scaling_governor)
115 self._original_scaling_governor = None 116 self._original_scaling_governor = None
116 117
117 def _SetScalingGovernorInternal(self, value): 118 def _SetScalingGovernorInternal(self, value):
118 for cpu in range(self._num_cpus): 119 for cpu in range(self._num_cpus):
119 self._adb.RunShellCommand( 120 self._adb.RunShellCommand(
120 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu)) 121 ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu))
122
123
124 class ThermalThrottle(object):
bulach 2012/10/31 10:44:47 it'd make sense to have this class in its own file
Anthony Berent 2012/10/31 15:14:02 Done.
125 """Class to detect and track thermal throttling
126
127 Usage:
128 Wait for IsThrottled() to be False before running test
129 After running test call HasBeenThrottled() to find out if the
130 test run was affected by thermal throttling.
131
132 Currently assumes an OMap device, but I don't know of any others with
bulach 2012/10/31 10:44:47 nit: people told me in the past to avoid using fir
Anthony Berent 2012/10/31 15:14:02 Done.
133 thermal throttling.
134 """
135 _throttled = False
bulach 2012/10/31 10:44:47 nit: this should be a regular member in __init__ (
Anthony Berent 2012/10/31 15:14:02 Done.
136
137 def __init__(self, adb):
138 self._adb = adb
139
140 def HasBeenThrottled(self):
141 """ True if there has been any throttling since the last call to
142 HasBeenThrottled or IsThrottled
143 """
144 return self._readLog()
145
146 def IsThrottled(self):
147 """True if currently throttled"""
148 self._readLog()
149 return self._throttled
150
151 def _readLog(self):
bulach 2012/10/31 10:44:47 nit: _ReadLog
Anthony Berent 2012/10/31 15:14:02 Done.
152 has_been_throttled = False
153 log = self._adb.RunShellCommand("dmesg -c")
bulach 2012/10/31 10:44:47 nit: single quotes on all strings here.
Anthony Berent 2012/10/31 15:14:02 Done.
154 for line in log:
155 if "omap_thermal_throttle" in line:
156 if not self._throttled:
157 logging.warning(">>> Thermally Throttled")
158 self._throttled = True
159 has_been_throttled = True
160 if "omap_thermal_unthrottle" in line:
161 if self._throttled:
162 logging.warning(">>> Thermally Unthrottled")
163 self._throttled = False
164 has_been_throttled = True
165 return has_been_throttled
166
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