Home | History | Annotate | Download | only in turbostat
      1 """
      2 turbostat prints out CPU stats
      3 """
      4 
      5 import os, subprocess, signal
      6 import logging
      7 from autotest_lib.client.bin import profiler, os_dep
      8 
      9 
     10 class turbostat(profiler.profiler):
     11     """
     12     turbostat reports processor topology, frequency, idle power-state
     13     statistics, etc.
     14     """
     15     version = 1
     16 
     17     def initialize(self):
     18         self.bin = os_dep.command('turbostat')
     19 
     20     def start(self, test):
     21         self._output = open(os.path.join(test.profdir, "turbostat"), "wt")
     22 
     23         cmd = [self.bin]
     24         logging.debug("Starting turbostat: %s", cmd)
     25 
     26         # Log the start time so a complete datetime can be computed later
     27         subprocess.call(['date', '-Iseconds'], stdout=self._output)
     28 
     29         self._process = subprocess.Popen(
     30                 cmd,
     31                 stdout=self._output,
     32                 stderr=subprocess.STDOUT,
     33                 close_fds=True)
     34 
     35     def stop(self, test):
     36         logging.debug("Stopping turbostat")
     37 
     38         os.kill(self._process.pid, signal.SIGTERM)
     39 
     40         self._process.wait()
     41 
     42         logging.debug("Stopped turbostat")
     43 
     44         self._output.close()
     45 
     46     def report(self, test):
     47         pass
     48