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 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 = utils.get_cpu_usage() time.sleep(MEASUREMENT_DURATION) cpu_usage_end = utils.get_cpu_usage() return utils.compute_active_cpu_time(cpu_usage_start, cpu_usage_end) * 100 # crbug/753292 - APNG login pictures increase CPU usage. Move the more # strict idle checks after the login phase. utils.wait_for_idle_cpu(WAIT_FOR_IDLE_CPU_TIMEOUT, CPU_IDLE_USAGE) utils.wait_for_cool_machine() if not utils.wait_for_idle_cpu(WAIT_FOR_IDLE_CPU_TIMEOUT, CPU_IDLE_USAGE): logging.warning('Could not get idle CPU pre login.') if not utils.wait_for_cool_machine(): logging.warning('Could not get cold machine pre login.') # Stop the thermal service that may change the cpu frequency. self._service_stopper = service_stopper.ServiceStopper( THERMAL_SERVICES) self._service_stopper.stop_services() # Set the scaling governor to performance mode to set the cpu to the # highest frequency available. self._original_governors = utils.set_high_performance_mode() return self.test_webrtc(local_path, get_cpu_usage)
def __enter__(self): # Stop the thermal service that may change the cpu frequency. self._service_stopper = service_stopper.ServiceStopper(THERMAL_SERVICES) self._service_stopper.stop_services() 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 cold machine.') # Set the scaling governor to performance mode to set the cpu to the # highest frequency available. self._original_governors = utils.set_high_performance_mode() return self
def __init__(self): self._service_stopper = None # Keep a copy of the current state for cleanup. self._temperature_init = utils.get_current_temperature_max() self._temperature_critical = utils.get_temperature_critical() self._original_governors = utils.set_high_performance_mode() self._error_reason = None if not utils.wait_for_idle_cpu(60.0, 0.1): self._error_reason = 'Could not get idle CPU.' return if not utils.wait_for_cool_machine(): self._error_reason = 'Could not get cold machine.' return self._temperature_cold = utils.get_current_temperature_max() self._temperature_max = self._temperature_cold threading.Thread(target=self._monitor_performance_state).start() # Should be last just in case we had a runaway process. self._stop_thermal_throttling()