Home | History | Annotate | Download | only in cpistat
      1 """
      2 Uses perf_events to count cycles and instructions
      3 
      4 Defaults options:
      5 job.profilers.add('cpistat', interval=1)
      6 """
      7 import time, os, subprocess
      8 from autotest_lib.client.bin import profiler
      9 
     10 class 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