On Mon, 2011-04-25 at 13:44 -0700, Scott James Remnant wrote:
> As well as reports, one of the other most useful things you can
> generate from perf is trace output. Support generating that with
> trace=True added to the profiler, e.g.:
>
> job.profilers.add('perf', events=['fs:*'], trace=True)
>
> the output is a raw trace file in the profiling directory.
Ok, LGTM, applied:
http://autotest.kernel.org/changeset/5327
Thanks!
> Change-Id: I84e1e0332611f5d31b44a4a5e9e7a11e73005364
> Signed-off-by: Scott James Remnant <[email protected]>
> ---
> client/profilers/perf/perf.py | 15 ++++++++++++++-
> 1 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/client/profilers/perf/perf.py b/client/profilers/perf/perf.py
> index e6f9bb7..70ed8aa 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
> @@ -36,6 +37,8 @@ class perf(profiler.profiler):
> self.logfile = os.path.join(test.profdir, "perf")
> cmd = ("%s record -a -o %s" %
> (self.perf_bin, self.logfile))
> + if self.trace:
> + cmd += " -R"
> for event in self.events:
> cmd += " -e %s" % event
> self._process = subprocess.Popen(cmd, shell=True,
> @@ -57,6 +60,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).',
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest