def test_cpu_usage(self, local_path): """ Runs the video cpu usage test. @param local_path: the path to the video file. @return a dictionary that contains the test result. """ def get_cpu_usage(cr): time.sleep(STABILIZATION_DURATION) cpu_usage_start = site_utils.get_cpu_usage() time.sleep(MEASUREMENT_DURATION) cpu_usage_end = site_utils.get_cpu_usage() return site_utils.compute_active_cpu_time(cpu_usage_start, cpu_usage_end) * 100 if not utils.wait_for_idle_cpu(WAIT_FOR_IDLE_CPU_TIMEOUT, CPU_IDLE_USAGE): raise error.TestError('Could not get idle CPU.') if not utils.wait_for_cool_machine(): raise error.TestError('Could not get cool machine.') # Stop the thermal service that may change the cpu frequency. services = service_stopper.ServiceStopper(THERMAL_SERVICES) services.stop_services() # Set the scaling governor to performance mode to set the cpu to the # highest frequency available. original_governors = utils.set_high_performance_mode() try: return self.test_webrtc(local_path, get_cpu_usage) finally: services.restore_services() utils.restore_scaling_governor_states(original_governors)
def __exit__(self, type, value, tb): if self._service_stopper: self._service_stopper.restore_services() self._service_stopper = None if self._original_governors: utils.restore_scaling_governor_states(self._original_governors) self._original_governors = None
def cleanup(self): if self._backlight: self._backlight.restore() if self._service_stopper: self._service_stopper.restore_services() if self._original_governors: utils.restore_scaling_governor_states(self._original_governors) super(video_WebRtcPerf, self).cleanup()
def cleanup(self): # cleanup() is run by common_lib/test.py. if self._backlight: self._backlight.restore() if self._service_stopper: self._service_stopper.restore_services() if self._original_governors: utils.restore_scaling_governor_states(self._original_governors) super(video_PlaybackPerf, self).cleanup()
def cleanup(self): """Autotest cleanup function It is run by common_lib/test.py. """ if self._backlight: self._backlight.restore() if self._service_stopper: self._service_stopper.restore_services() if self._original_governors: utils.restore_scaling_governor_states(self._original_governors) if self._use_ec: power_utils.charge_control_by_ectool(is_charge=True) super(video_JDAPerf, self).cleanup()
def __exit__(self, _type, value, traceback): # First thing restart thermal management. self._restore_thermal_throttling() utils.restore_scaling_governor_states(self._original_governors)