Chromium Code Reviews| Index: tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend.py |
| diff --git a/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend.py b/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend.py |
| index 8a7ddd0d81593fd16f8825b97c2a98c684106e4b..12162e096dbfc3b145e19739f83117b085b75dfc 100644 |
| --- a/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend.py |
| +++ b/tools/telemetry/telemetry/core/platform/proc_supporting_platform_backend.py |
| @@ -2,6 +2,8 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import collections |
| + |
| try: |
| import resource # pylint: disable=F0401 |
| except ImportError: |
| @@ -32,6 +34,22 @@ class ProcSupportingPlatformBackend(platform_backend.PlatformBackend): |
| meminfo = self._GetProcFileDict(meminfo_contents) |
| return self._ConvertKbToByte(meminfo['MemTotal']) |
| + def GetGlobalCpuStats(self): |
| + num_cpus = int(self._GetFileContents( |
| + '/sys/devices/system/cpu/kernel_max')) |
| + cpu_frequencies = collections.defaultdict(int) |
| + for cpu in range(num_cpus): |
| + try: |
| + stats = self._GetFileContents( |
| + '/sys/devices/system/cpu/cpu%d/cpufreq/stats/time_in_state' % |
| + cpu) |
| + for e in stats.splitlines(): |
| + k, v = e.split() |
| + cpu_frequencies[int(k)] += int(v) |
|
pasko
2014/04/22 14:06:30
I'm concerned with the story towards two vectors:
|
| + except IOError: |
| + continue |
| + return {'GlobalCpuFrequencyStats': cpu_frequencies} |
| + |
| def GetCpuStats(self, pid): |
| stats = self._GetProcFileForPid(pid, 'stat') |
| if not stats: |