OLD | NEW |
1 """ | 1 """ |
2 Uses perf_events to count cycles and instructions | 2 Uses perf_events to count cycles and instructions |
3 | 3 |
4 Defaults options: | 4 Defaults options: |
5 job.profilers.add('cpistat', interval=1) | 5 job.profilers.add('cpistat', interval=1) |
6 """ | 6 """ |
7 import time, os, subprocess | 7 import time, os, subprocess |
8 from autotest_lib.client.bin import profiler | 8 from autotest_lib.client.bin import profiler |
9 | 9 |
10 class cpistat(profiler.profiler): | 10 class cpistat(profiler.profiler): |
11 version = 1 | 11 version = 1 |
12 | 12 |
13 def initialize(self, interval = 1): | 13 def initialize(self, interval = 1): |
14 self.interval = interval | 14 self.interval = interval |
15 | 15 |
16 | 16 |
17 def start(self, test): | 17 def start(self, test): |
18 cmd = os.path.join(self.bindir, 'site_cpistat') | 18 cmd = os.path.join(self.bindir, 'site_cpistat') |
19 if not os.path.exists(cmd): | 19 if not os.path.exists(cmd): |
20 cmd = os.path.join(self.bindir, 'cpistat') | 20 cmd = os.path.join(self.bindir, 'cpistat') |
21 logfile = open(os.path.join(test.profdir, "cpistat"), 'w') | 21 logfile = open(os.path.join(test.profdir, "cpistat"), 'w') |
22 p = subprocess.Popen(cmd, stdout=logfile, | 22 p = subprocess.Popen(cmd, stdout=logfile, |
23 stderr=subprocess.STDOUT) | 23 stderr=subprocess.STDOUT) |
24 self.pid = p.pid | 24 self.pid = p.pid |
25 | 25 |
26 | 26 |
27 def stop(self, test): | 27 def stop(self, test): |
28 os.kill(self.pid, 15) | 28 os.kill(self.pid, 15) |
OLD | NEW |