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

Unified Diff: client/profilers/perf/perf.py

Issue 6883246: Merge autotest upstream from @5318 ~ @5336 (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 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 | « client/common_lib/cartesian_config.py ('k') | client/tests/kvm/build.cfg.sample » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/profilers/perf/perf.py
diff --git a/client/profilers/perf/perf.py b/client/profilers/perf/perf.py
index e6f9bb71afd441cf1b42e416087e476b0d1b629f..b9ad34f7a5982d0f6a3449318aba0dd8726d6183 100644
--- a/client/profilers/perf/perf.py
+++ b/client/profilers/perf/perf.py
@@ -13,11 +13,12 @@ from autotest_lib.client.bin import profiler, os_dep, utils
class perf(profiler.profiler):
version = 1
- def initialize(self, events=["cycles","instructions"]):
+ def initialize(self, events=["cycles","instructions"], trace=False):
if type(events) == str:
self.events = [events]
else:
self.events = events
+ self.trace = trace
self.perf_bin = os_dep.command('perf')
perf_help = utils.run('%s report help' % self.perf_bin,
ignore_status=True).stderr
@@ -25,7 +26,7 @@ class perf(profiler.profiler):
for line in perf_help.split('\n'):
a = "sort by key(s):"
if a in line:
- line = line.strip(a)
+ line = line.replace(a, "")
self.sort_keys = [k.rstrip(",") for k in line.split() if
k.rstrip(",") != 'dso']
if not self.sort_keys:
@@ -34,8 +35,12 @@ class perf(profiler.profiler):
def start(self, test):
self.logfile = os.path.join(test.profdir, "perf")
- cmd = ("%s record -a -o %s" %
+ cmd = ("exec %s record -a -o %s" %
(self.perf_bin, self.logfile))
+ if "parent" in self.sort_keys:
+ cmd += " -g"
+ if self.trace:
+ cmd += " -R"
for event in self.events:
cmd += " -e %s" % event
self._process = subprocess.Popen(cmd, shell=True,
@@ -57,6 +62,16 @@ class perf(profiler.profiler):
p = subprocess.Popen(cmd, shell=True, stdout=outfile,
stderr=subprocess.STDOUT)
p.wait()
+
+ if self.trace:
+ tracefile = os.path.join(test.profdir, 'trace')
+ cmd = ("%s trace -i %s" % (self.perf_bin, self.logfile,))
+
+ outfile = open(tracefile, 'w')
+ p = subprocess.Popen(cmd, shell=True, stdout=outfile,
+ stderr=subprocess.STDOUT)
+ p.wait()
+
# The raw detailed perf output is HUGE. We cannot store it by default.
perf_log_size = os.stat(self.logfile)[stat.ST_SIZE]
logging.info('Removing %s after generating reports (saving %s bytes).',
« no previous file with comments | « client/common_lib/cartesian_config.py ('k') | client/tests/kvm/build.cfg.sample » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698