| OLD | NEW |
| 1 """ | 1 """ |
| 2 What's eating the battery life of my laptop? Why isn't it many more | 2 What's eating the battery life of my laptop? Why isn't it many more |
| 3 hours? Which software component causes the most power to be burned? | 3 hours? Which software component causes the most power to be burned? |
| 4 These are important questions without a good answer... until now. | 4 These are important questions without a good answer... until now. |
| 5 """ | 5 """ |
| 6 import time, os | 6 import time, os |
| 7 from autotest_lib.client.bin import utils, profiler | 7 from autotest_lib.client.bin import utils, profiler |
| 8 | 8 |
| 9 class powertop(profiler.profiler): | 9 class powertop(profiler.profiler): |
| 10 version = 1 | 10 version = 1 |
| 11 preserve_srcdir = True | 11 preserve_srcdir = True |
| 12 | 12 |
| 13 # filenames: list of filenames to cat | 13 # filenames: list of filenames to cat |
| 14 def setup(self, *args, **dargs): | 14 def setup(self, *args, **dargs): |
| 15 os.chdir(self.srcdir) | 15 os.chdir(self.srcdir) |
| 16 utils.make() | 16 utils.system('make') |
| 17 | 17 |
| 18 | 18 |
| 19 def start(self, test): | 19 def start(self, test): |
| 20 self.child_pid = os.fork() | 20 self.child_pid = os.fork() |
| 21 if self.child_pid: # parent | 21 if self.child_pid: # parent |
| 22 return None | 22 return None |
| 23 else: # child | 23 else: # child |
| 24 powertop = os.path.join(self.srcdir, 'powertop') + ' -d' | 24 powertop = os.path.join(self.srcdir, 'powertop') + ' -d' |
| 25 outputfile = os.path.join(test.profdir, 'powertop') | 25 outputfile = os.path.join(test.profdir, 'powertop') |
| 26 while True: | 26 while True: |
| 27 output = open(outputfile, 'a') | 27 output = open(outputfile, 'a') |
| 28 output.write(time.asctime() + '\n') | 28 output.write(time.asctime() + '\n') |
| 29 data = utils.system_output('%s >> %s' % (powertop, outputfile)) | 29 data = utils.system_output('%s >> %s' % (powertop, outputfile)) |
| 30 output.write(data) | 30 output.write(data) |
| 31 output.write('\n=========================\n') | 31 output.write('\n=========================\n') |
| 32 output.close() | 32 output.close() |
| 33 | 33 |
| 34 | 34 |
| 35 def stop(self, test): | 35 def stop(self, test): |
| 36 os.kill(self.child_pid, 15) | 36 os.kill(self.child_pid, 15) |
| 37 | 37 |
| 38 | 38 |
| 39 def report(self, test): | 39 def report(self, test): |
| 40 return None | 40 return None |
| OLD | NEW |