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