Chromium Code Reviews| Index: tools/telemetry/telemetry/core/platform/proc_util.py |
| diff --git a/tools/telemetry/telemetry/core/platform/proc_util.py b/tools/telemetry/telemetry/core/platform/proc_util.py |
| index 656eb846996b227b9d864798f4793191f2134b15..8b3bb6ece5b0d1e4ead1d2c55247e97c0e1fc713 100644 |
| --- a/tools/telemetry/telemetry/core/platform/proc_util.py |
| +++ b/tools/telemetry/telemetry/core/platform/proc_util.py |
| @@ -22,6 +22,18 @@ def _GetProcFileDict(contents): |
| return retval |
| +def _GetProcJiffies(timer_list): |
| + """Parse '/proc/timer_list' output and returns the first jiffies attribute. |
| + |
| + Multi-CPU machines will have multiple 'jiffies:' lines, all of which will be |
| + essentially the same. Return the first one.""" |
| + for line in timer_list.splitlines(): |
| + if line.startswith('jiffies:'): |
| + _, value = line.split(':') |
| + return value |
| + return 0 |
|
tonyg
2013/09/06 17:42:15
Should this raise?
edmundyan
2013/09/06 21:24:51
Done.
|
| + |
| + |
| def GetSystemCommitCharge(meminfo_contents): |
| meminfo = _GetProcFileDict(meminfo_contents) |
| return (_ConvertKbToByte(meminfo['MemTotal']) |
| @@ -30,6 +42,21 @@ def GetSystemCommitCharge(meminfo_contents): |
| - _ConvertKbToByte(meminfo['Cached'])) |
| +def GetCpuStats(timer_list, stats, add_children=False): |
| + utime = float(stats[13]) |
| + stime = float(stats[14]) |
| + cutime = float(stats[15]) |
| + cstime = float(stats[16]) |
| + total_jiffies = float(_GetProcJiffies(timer_list)) |
| + |
| + cpu_process_jiffies = utime + stime |
| + if add_children: |
| + cpu_process_jiffies += cutime + cstime |
| + |
| + return {'CpuProcessTime': cpu_process_jiffies, |
| + 'TotalTime': total_jiffies} |
| + |
| + |
| def GetMemoryStats(status_contents, stats): |
| status = _GetProcFileDict(status_contents) |
| if not status or not stats or 'Z' in status['State']: |