示例#1
0
 def __init__(self, pid, output_path):
   self._output_path = output_path
   output_dir = os.path.dirname(self._output_path)
   output_file = os.path.basename(self._output_path)
   self._proc = pexpect.spawn(
       'iprofiler', ['-timeprofiler', '-T', '300', '-a', str(pid),
                     '-d', output_dir, '-o', output_file],
       timeout=300)
   while True:
     if self._proc.getecho():
       output = self._proc.readline().strip()
       if not output:
         continue
       if 'iprofiler: Profiling process' in output:
         break
       print output
     self._proc.interact(escape_character='\x0d')
     if 'Failed to authorize rights' in output:
       raise exceptions.ProfilingException(
           'Failed to authorize rights for iprofiler\n')
     if 'iprofiler error' in output:
       raise exceptions.ProfilingException(
           'Failed to start iprofiler for process %s\n' %
           self._output_path.split('.')[1])
     self._proc.write('\x0d')
     print
     def Echo():
       return self._proc.getecho()
     util.WaitFor(Echo, timeout=5)
示例#2
0
 def IsStarted():
     stdout = self._GetStdOut()
     if 'sample cannot examine process' in stdout:
         raise exceptions.ProfilingException(
             'Failed to start sample for process %s\n' %
             self._output_path.split('.')[1])
     return 'Sampling process' in stdout
 def __init__(self, browser_backend, platform_backend, output_path, state):
   super(MonsoonProfiler, self).__init__(
       browser_backend, platform_backend, output_path, state)
   # We collect the data in a separate process, so we can continuously
   # read the samples from the USB port while running the test.
   self._is_collecting = multiprocessing.Event()
   self._collector = multiprocessing.Process(
       target=_CollectData, args=(output_path, self._is_collecting))
   self._collector.start()
   if not self._is_collecting.wait(timeout=0.5):
     self._collector.terminate()
     raise exceptions.ProfilingException('Failed to start data collection.')
示例#4
0
 def StartMonitoringPowerAsync(self):
     assert not self._powermonitor_process, (
         'Must call StopMonitoringPowerAsync().')
     self._powermonitor_output_file = tempfile.TemporaryFile()
     self._is_collecting = multiprocessing.Event()
     self._powermonitor_process = multiprocessing.Process(
         target=_MonitorPower,
         args=(self._monsoon, self._is_collecting,
               self._powermonitor_output_file))
     self._powermonitor_process.start()
     if not self._is_collecting.wait(timeout=0.5):
         self._powermonitor_process.terminate()
         raise exceptions.ProfilingException(
             'Failed to start data collection.')
示例#5
0
 def StartMonitoringPower(self, browser):
   self._CheckStart()
   self._powermonitor_output_file = tempfile.TemporaryFile()
   self._is_collecting = multiprocessing.Event()
   self._powermonitor_process = multiprocessing.Process(
       target=_MonitorPower,
       args=(self._monsoon,
             self._is_collecting,
             self._powermonitor_output_file))
   # Ensure child is not left behind: parent kills daemonic children on exit.
   self._powermonitor_process.daemon = True
   self._powermonitor_process.start()
   if not self._is_collecting.wait(timeout=0.5):
     self._powermonitor_process.terminate()
     raise exceptions.ProfilingException('Failed to start data collection.')