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

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: Only store the timestamp once instead of summing it 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
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..1449f6aaf2eee97530f3cdde3352e1617c8badb7 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
+ raise Exception('Unable to find jiffies from /proc/timer_list')
+
+
def GetSystemCommitCharge(meminfo_contents):
meminfo = _GetProcFileDict(meminfo_contents)
return (_ConvertKbToByte(meminfo['MemTotal'])
@@ -30,6 +42,25 @@ def GetSystemCommitCharge(meminfo_contents):
- _ConvertKbToByte(meminfo['Cached']))
+def GetCpuStats(stats, add_children=False):
+ utime = float(stats[13])
+ stime = float(stats[14])
+ cutime = float(stats[15])
+ cstime = float(stats[16])
+
+ cpu_process_jiffies = utime + stime
+ if add_children:
+ cpu_process_jiffies += cutime + cstime
+
+ return {'CpuProcessTime': cpu_process_jiffies}
+
+
+def GetTimestampJiffies(timer_list):
+ """Return timestamp of system in jiffies."""
+ total_jiffies = float(_GetProcJiffies(timer_list))
+ return {'TotalTime': total_jiffies}
+
+
def GetMemoryStats(status_contents, stats):
status = _GetProcFileDict(status_contents)
if not status or not stats or 'Z' in status['State']:

Powered by Google App Engine
This is Rietveld 408576698