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

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

Issue 1106043003: [Telemetry] Improve _GetProcJiffies operation with using grep. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698