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

Unified Diff: tools/telemetry/telemetry/core/platform/proc_util.py

Issue 23717016: Add cpu_stats for the browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finalize jiffies. Remove unittests Created 7 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/platform/platform_backend.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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']:
« no previous file with comments | « tools/telemetry/telemetry/core/platform/platform_backend.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698