| OLD | NEW |
| 1 """ | 1 """ |
| 2 perf is a tool included in the linux kernel tree that | 2 perf is a tool included in the linux kernel tree that |
| 3 supports functionality similar to oprofile and more. | 3 supports functionality similar to oprofile and more. |
| 4 | 4 |
| 5 @see: http://lwn.net/Articles/310260/ | 5 @see: http://lwn.net/Articles/310260/ |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 import time, os, stat, subprocess, signal | 8 import time, os, subprocess, signal |
| 9 import logging | |
| 10 from autotest_lib.client.bin import profiler, os_dep, utils | 9 from autotest_lib.client.bin import profiler, os_dep, utils |
| 11 | 10 |
| 12 | 11 |
| 13 class perf(profiler.profiler): | 12 class perf(profiler.profiler): |
| 14 version = 1 | 13 version = 1 |
| 15 | 14 |
| 16 def initialize(self, events="cycles,instructions"): | 15 def initialize(self, events="cycles,instructions"): |
| 17 self.events = events | 16 self.events = events |
| 18 self.perf_bin = os_dep.command('perf') | 17 self.perf_bin = os_dep.command('perf') |
| 19 perf_help = utils.run('%s report help' % self.perf_bin, | 18 perf_help = utils.run('%s report help' % self.perf_bin, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 45 def report(self, test): | 44 def report(self, test): |
| 46 for key in self.sort_keys: | 45 for key in self.sort_keys: |
| 47 reportfile = os.path.join(test.profdir, '%s.comm' % key) | 46 reportfile = os.path.join(test.profdir, '%s.comm' % key) |
| 48 cmd = ("%s report -i %s --sort %s,dso" % (self.perf_bin, | 47 cmd = ("%s report -i %s --sort %s,dso" % (self.perf_bin, |
| 49 self.logfile, | 48 self.logfile, |
| 50 key)) | 49 key)) |
| 51 outfile = open(reportfile, 'w') | 50 outfile = open(reportfile, 'w') |
| 52 p = subprocess.Popen(cmd, shell=True, stdout=outfile, | 51 p = subprocess.Popen(cmd, shell=True, stdout=outfile, |
| 53 stderr=subprocess.STDOUT) | 52 stderr=subprocess.STDOUT) |
| 54 p.wait() | 53 p.wait() |
| 55 # The raw detailed perf output is HUGE. We cannot store it by default. | |
| 56 perf_log_size = os.stat(self.logfile)[stat.ST_SIZE] | |
| 57 logging.info('Removing %s after generating reports (saving %s bytes).', | |
| 58 self.logfile, perf_log_size) | |
| 59 os.unlink(self.logfile) | |
| OLD | NEW |