Source code for autotest.client.profilers.readprofile.readprofile

"""
readprofile - a tool to read kernel profiling information

The readprofile command uses the /proc/profile information to print ascii data
on standard output. The output is organized in three columns: the first is the
number of clock ticks, the second is the name of the C function in the kernel
where those many ticks occurred, and the third is the normalized `load' of the
procedure, calculated as a ratio between the number of ticks and the length of
the procedure. The output is filled with blanks to ease readability.
"""
import os
import shutil

from autotest.client import utils, profiler
from autotest.client.shared import error


[docs]class readprofile(profiler.profiler): version = 1 # http://www.kernel.org/pub/linux/utils/util-linux/util-linux-2.12r.tar.bz2
[docs] def setup(self, tarball='util-linux-2.12r.tar.bz2'): self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) utils.extract_tarball_to_dir(self.tarball, self.srcdir) os.chdir(self.srcdir) utils.configure() os.chdir('sys-utils') utils.make('readprofile')
[docs] def initialize(self, **dargs): self.job.require_gcc() try: utils.system('grep -iq " profile=" /proc/cmdline') except error.CmdError: raise error.AutotestError('readprofile not enabled') self.cmd = self.srcdir + '/sys-utils/readprofile'
[docs] def start(self, test): utils.system(self.cmd + ' -r')
[docs] def stop(self, test): # There's no real way to stop readprofile, so we stash the # raw data at this point instead. BAD EXAMPLE TO COPY! ;-) self.rawprofile = test.profdir + '/profile.raw' print "STOP" shutil.copyfile('/proc/profile', self.rawprofile)
[docs] def report(self, test): args = ' -n' args += ' -m ' + utils.get_systemmap() args += ' -p ' + self.rawprofile cmd = self.cmd + ' ' + args txtprofile = test.profdir + '/profile.text' utils.system(cmd + ' | sort -nr > ' + txtprofile) utils.system('bzip2 ' + self.rawprofile)