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, subprocess, signal | 8 import time, os, stat, subprocess, signal |
| 9 import logging |
9 from autotest_lib.client.bin import profiler, os_dep, utils | 10 from autotest_lib.client.bin import profiler, os_dep, utils |
10 | 11 |
11 | 12 |
12 class perf(profiler.profiler): | 13 class perf(profiler.profiler): |
13 version = 1 | 14 version = 1 |
14 | 15 |
15 def initialize(self, events="cycles,instructions"): | 16 def initialize(self, events="cycles,instructions"): |
16 self.events = events | 17 self.events = events |
17 self.perf_bin = os_dep.command('perf') | 18 self.perf_bin = os_dep.command('perf') |
18 perf_help = utils.run('%s report help' % self.perf_bin, | 19 perf_help = utils.run('%s report help' % self.perf_bin, |
(...skipping 25 matching lines...) Expand all Loading... |
44 def report(self, test): | 45 def report(self, test): |
45 for key in self.sort_keys: | 46 for key in self.sort_keys: |
46 reportfile = os.path.join(test.profdir, '%s.comm' % key) | 47 reportfile = os.path.join(test.profdir, '%s.comm' % key) |
47 cmd = ("%s report -i %s --sort %s,dso" % (self.perf_bin, | 48 cmd = ("%s report -i %s --sort %s,dso" % (self.perf_bin, |
48 self.logfile, | 49 self.logfile, |
49 key)) | 50 key)) |
50 outfile = open(reportfile, 'w') | 51 outfile = open(reportfile, 'w') |
51 p = subprocess.Popen(cmd, shell=True, stdout=outfile, | 52 p = subprocess.Popen(cmd, shell=True, stdout=outfile, |
52 stderr=subprocess.STDOUT) | 53 stderr=subprocess.STDOUT) |
53 p.wait() | 54 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 |