| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 collections | 5 import collections |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 from telemetry import decorators | 10 from telemetry import decorators |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 def GetCpuState(self): | 83 def GetCpuState(self): |
| 84 """Retrieve CPU c-state residency times from the device. | 84 """Retrieve CPU c-state residency times from the device. |
| 85 | 85 |
| 86 Returns: | 86 Returns: |
| 87 Dictionary containing c-state residency times for each CPU. | 87 Dictionary containing c-state residency times for each CPU. |
| 88 """ | 88 """ |
| 89 stats = {} | 89 stats = {} |
| 90 for cpu in self._cpus: | 90 for cpu in self._cpus: |
| 91 cpu_state_path = os.path.join(CPU_PATH, cpu, 'cpuidle/state*') | 91 cpu_state_path = os.path.join(CPU_PATH, cpu, 'cpuidle/state*') |
| 92 stats[cpu] = self._platform.RunCommand( | 92 output = self._platform.RunCommand( |
| 93 'cat %s %s %s; date +%%s' % (os.path.join(cpu_state_path, 'name'), | 93 'cat %s %s %s; date +%%s' % ( |
| 94 os.path.join(cpu_state_path, 'time'), | 94 os.path.join(cpu_state_path, 'name'), |
| 95 os.path.join(cpu_state_path, 'latency'))) | 95 os.path.join(cpu_state_path, 'time'), |
| 96 os.path.join(cpu_state_path, 'latency'))) |
| 97 stats[cpu] = re.sub('\n\n+', '\n', output) |
| 96 return stats | 98 return stats |
| 97 | 99 |
| 98 def GetCpuFreq(self): | 100 def GetCpuFreq(self): |
| 99 """Retrieve CPU frequency times from the device. | 101 """Retrieve CPU frequency times from the device. |
| 100 | 102 |
| 101 Returns: | 103 Returns: |
| 102 Dictionary containing frequency times for each CPU. | 104 Dictionary containing frequency times for each CPU. |
| 103 """ | 105 """ |
| 104 stats = {} | 106 stats = {} |
| 105 for cpu in self._cpus: | 107 for cpu in self._cpus: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 Returns: | 194 Returns: |
| 193 Dictionary in the format returned by StopMonitoringPower. | 195 Dictionary in the format returned by StopMonitoringPower. |
| 194 """ | 196 """ |
| 195 if not cpu_stats: | 197 if not cpu_stats: |
| 196 return power_stats | 198 return power_stats |
| 197 if 'component_utilization' not in power_stats: | 199 if 'component_utilization' not in power_stats: |
| 198 power_stats['component_utilization'] = {} | 200 power_stats['component_utilization'] = {} |
| 199 for cpu in cpu_stats: | 201 for cpu in cpu_stats: |
| 200 power_stats['component_utilization'][cpu] = cpu_stats[cpu] | 202 power_stats['component_utilization'][cpu] = cpu_stats[cpu] |
| 201 return power_stats | 203 return power_stats |
| OLD | NEW |