| OLD | NEW |
| 1 import glob, logging, os, re, time | 1 import glob, logging, os, re, time |
| 2 from autotest_lib.client.bin import utils as bin_utils | 2 from autotest_lib.client.bin import utils |
| 3 from autotest_lib.client.common_lib import error, utils | 3 from autotest_lib.client.common_lib import error |
| 4 | 4 |
| 5 | 5 |
| 6 class DevStat(object): | 6 class DevStat(object): |
| 7 """ | 7 """ |
| 8 Device power status. This class implements generic status initialization | 8 Device power status. This class implements generic status initialization |
| 9 and parsing routines. | 9 and parsing routines. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 def __init__(self, fields, path=None): | 12 def __init__(self, fields, path=None): |
| 13 self.fields = fields | 13 self.fields = fields |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 class CPUIdleStats(object): | 256 class CPUIdleStats(object): |
| 257 """ | 257 """ |
| 258 CPU Idle statistics | 258 CPU Idle statistics |
| 259 """ | 259 """ |
| 260 # TODO (snanda): Handle changes in number of c-states due to events such | 260 # TODO (snanda): Handle changes in number of c-states due to events such |
| 261 # as ac <-> battery transitions. | 261 # as ac <-> battery transitions. |
| 262 # TODO (snanda): Handle non-S0 states. Time spent in suspend states is | 262 # TODO (snanda): Handle non-S0 states. Time spent in suspend states is |
| 263 # currently not factored out. | 263 # currently not factored out. |
| 264 | 264 |
| 265 def __init__(self): | 265 def __init__(self): |
| 266 self._num_cpus = bin_utils.count_cpus() | 266 self._num_cpus = utils.count_cpus() |
| 267 self._time = time.time() | 267 self._time = time.time() |
| 268 self._stats = self._read_stats() | 268 self._stats = self._read_stats() |
| 269 | 269 |
| 270 | 270 |
| 271 def refresh(self): | 271 def refresh(self): |
| 272 """ | 272 """ |
| 273 This method returns the percentage time spent in each of the CPU | 273 This method returns the percentage time spent in each of the CPU |
| 274 idle states. The stats returned are from whichever is the later of: | 274 idle states. The stats returned are from whichever is the later of: |
| 275 a) time this class was instantiated, or | 275 a) time this class was instantiated, or |
| 276 b) time when refresh was last called | 276 b) time when refresh was last called |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 389 |
| 390 active = int(utils.read_file(active_duration_path)) | 390 active = int(utils.read_file(active_duration_path)) |
| 391 connected = int(utils.read_file(connected_duration_path)) | 391 connected = int(utils.read_file(connected_duration_path)) |
| 392 logging.debug('device %s active for %.2f%%', | 392 logging.debug('device %s active for %.2f%%', |
| 393 path, active * 100.0 / connected) | 393 path, active * 100.0 / connected) |
| 394 | 394 |
| 395 total_active += active | 395 total_active += active |
| 396 total_connected += connected | 396 total_connected += connected |
| 397 | 397 |
| 398 return total_active, total_connected | 398 return total_active, total_connected |
| OLD | NEW |