Index: tools/telemetry/telemetry/core/platform/linux_based_platform_backend.py |
diff --git a/tools/telemetry/telemetry/core/platform/linux_based_platform_backend.py b/tools/telemetry/telemetry/core/platform/linux_based_platform_backend.py |
index 6da162849aaa3303454f26d01023acba61c4f451..44bec8e2acb5855c8f333d69952e7e4200b0ac2c 100644 |
--- a/tools/telemetry/telemetry/core/platform/linux_based_platform_backend.py |
+++ b/tools/telemetry/telemetry/core/platform/linux_based_platform_backend.py |
@@ -53,8 +53,7 @@ class LinuxBasedPlatformBackend(platform_backend.PlatformBackend): |
return results |
def GetCpuTimestamp(self): |
- timer_list = self.GetFileContents('/proc/timer_list') |
- total_jiffies = float(self._GetProcJiffies(timer_list)) |
+ total_jiffies = self._GetProcJiffies() |
clock_ticks = self.GetClockTicks() |
return {'TotalTime': total_jiffies / clock_ticks} |
@@ -146,15 +145,15 @@ class LinuxBasedPlatformBackend(platform_backend.PlatformBackend): |
retval[key.strip()] = value.strip() |
return retval |
- def _GetProcJiffies(self, timer_list): |
+ def _GetProcJiffies(self): |
"""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.""" |
- if isinstance(timer_list, str): |
- timer_list = timer_list.splitlines() |
- for line in timer_list: |
- if line.startswith('jiffies:'): |
- _, value = line.split(':') |
- return value |
- raise Exception('Unable to find jiffies from /proc/timer_list') |
+ first_jiffies_timer_line = self.RunCommand( |
+ ['grep', '-m', '1', 'jiffies:','/proc/timer_list']) |
aiolos (Not reviewing)
2015/04/24 23:55:15
I'm a little wary of this change because it makes
jbudorick
2015/04/24 23:56:56
Agreed, this seems like too much of an optimizatio
aiolos (Not reviewing)
2015/04/25 00:53:55
I'm much happier with that idea.
nednguyen
2015/04/25 02:02:07
Good call, done. I use regex so the parsing is mo
|
+ if not first_jiffies_timer_line: |
+ raise Exception('Unable to find jiffies from /proc/timer_list') |
+ # The line should look something like 'jiffies: 4315883489'. |
+ _, value = first_jiffies_timer_line.split(':') |
+ return float(value) |