parameters: (self, _, results)
docstring: Add the collected power data into the results object.
  
      This function needs to be robust in the face of differing power data on
      various platforms. Therefore data existence needs to be checked when
      building up the results. Additionally 0 is a valid value for many of the
      metrics here which is why there are plenty of checks for 'is not None'
      below.
docstring_summary: Add the collected power data into the results object.
docstring_tokens: Add the collected power data into the results object .
function: def AddResults(self, _, results):
      """Add the collected power data into the results object.
  
      This function needs to be robust in the face of differing power data on
      various platforms. Therefore data existence needs to be checked when
      building up the results. Additionally 0 is a valid value for many of the
      metrics here which is why there are plenty of checks for 'is not None'
      below.
      """
      if not self._results:
        return
  
      application_energy_consumption_mwh = self._results.get(APP_POWER_LABEL)
      total_energy_consumption_mwh = self._results.get(TOTAL_POWER_LABEL)
      fuel_gauge_energy_consumption_mwh = self._results.get(
          FUELGAUGE_POWER_LABEL)
      monsoon_energy_consumption_mwh = self._results.get(MONSOON_POWER_LABEL)
  
      if (PowerMetric._quiescent_power_draw_mwh and
          application_energy_consumption_mwh is None and
          total_energy_consumption_mwh is not None):
        application_energy_consumption_mwh = max(
            total_energy_consumption_mwh - PowerMetric._quiescent_power_draw_mwh,
            0)
  
      if fuel_gauge_energy_consumption_mwh is not None:
        results.AddValue(scalar.ScalarValue(
            results.current_page, FUELGAUGE_POWER_LABEL, 'mWh',
            fuel_gauge_energy_consumption_mwh))
  
      if monsoon_energy_consumption_mwh is not None:
        results.AddValue(scalar.ScalarValue(
            results.current_page, MONSOON_POWER_LABEL, 'mWh',
            monsoon_energy_consumption_mwh))
  
      if total_energy_consumption_mwh is not None:
        results.AddValue(scalar.ScalarValue(
            results.current_page, TOTAL_POWER_LABEL, 'mWh',
            total_energy_consumption_mwh))
  
      if application_energy_consumption_mwh is not None:
        results.AddValue(scalar.ScalarValue(
            results.current_page, APP_POWER_LABEL, 'mWh',
            application_energy_consumption_mwh))
  
      component_utilization = self._results.get('component_utilization', {})
      # GPU Frequency.
      gpu_power = component_utilization.get('gpu', {})
      gpu_freq_hz = gpu_power.get('average_frequency_hz')
      if gpu_freq_hz is not None:
        results.AddValue(scalar.ScalarValue(
            results.current_page, 'gpu_average_frequency_hz', 'hz', gpu_freq_hz,
            important=False))
  
      # Add idle wakeup numbers for all processes.
      for (process_type, stats) in self._results.get('cpu_stats', {}).items():
        trace_name_for_process = 'idle_wakeups_%s' % (process_type.lower())
        results.AddValue(scalar.ScalarValue(
            results.current_page, trace_name_for_process, 'count', stats,
            important=False))
  
      # Add temperature measurements.
      platform_info_utilization = self._results.get('platform_info', {})
      board_temperature_c = platform_info_utilization.get(
          'average_temperature_c')
      if board_temperature_c is not None:
        results.AddValue(scalar.ScalarValue(
            results.current_page, 'board_temperature', 'celsius',
            board_temperature_c, important=False))
  
      # Add CPU frequency measurements.
      frequency_hz = platform_info_utilization.get('frequency_percent')
      if frequency_hz is not None:
        frequency_sum = 0.0
        for freq, percent in frequency_hz.iteritems():
          frequency_sum += freq * (percent / 100.0)
        results.AddValue(scalar.ScalarValue(
            results.current_page, 'cpu_average_frequency_hz', 'Hz',
            frequency_sum, important=False))
  
      # Add CPU c-state residency measurements.
      cstate_percent = platform_info_utilization.get('cstate_residency_percent')
      if cstate_percent is not None:
        for state, percent in cstate_percent.iteritems():
          results.AddValue(scalar.ScalarValue(
              results.current_page, 'cpu_cstate_%s_residency_percent' % state,
              '%', percent, important=False))
  
      self._results = None
function_tokens: def AddResults ( self , _ , results ) : if not self . _results : return application_energy_consumption_mwh = self . _results . get ( APP_POWER_LABEL ) total_energy_consumption_mwh = self . _results . get ( TOTAL_POWER_LABEL ) fuel_gauge_energy_consumption_mwh = self . _results . get ( FUELGAUGE_POWER_LABEL ) monsoon_energy_consumption_mwh = self . _results . get ( MONSOON_POWER_LABEL ) if ( PowerMetric . _quiescent_power_draw_mwh and application_energy_consumption_mwh is None and total_energy_consumption_mwh is not None ) : application_energy_consumption_mwh = max ( total_energy_consumption_mwh - PowerMetric . _quiescent_power_draw_mwh , 0 ) if fuel_gauge_energy_consumption_mwh is not None : results . AddValue ( scalar . ScalarValue ( results . current_page , FUELGAUGE_POWER_LABEL , 'mWh' , fuel_gauge_energy_consumption_mwh ) ) if monsoon_energy_consumption_mwh is not None : results . AddValue ( scalar . ScalarValue ( results . current_page , MONSOON_POWER_LABEL , 'mWh' , monsoon_energy_consumption_mwh ) ) if total_energy_consumption_mwh is not None : results . AddValue ( scalar . ScalarValue ( results . current_page , TOTAL_POWER_LABEL , 'mWh' , total_energy_consumption_mwh ) ) if application_energy_consumption_mwh is not None : results . AddValue ( scalar . ScalarValue ( results . current_page , APP_POWER_LABEL , 'mWh' , application_energy_consumption_mwh ) ) component_utilization = self . _results . get ( 'component_utilization' , { } ) # GPU Frequency. gpu_power = component_utilization . get ( 'gpu' , { } ) gpu_freq_hz = gpu_power . get ( 'average_frequency_hz' ) if gpu_freq_hz is not None : results . AddValue ( scalar . ScalarValue ( results . current_page , 'gpu_average_frequency_hz' , 'hz' , gpu_freq_hz , important = False ) ) # Add idle wakeup numbers for all processes. for ( process_type , stats ) in self . _results . get ( 'cpu_stats' , { } ) . items ( ) : trace_name_for_process = 'idle_wakeups_%s' % ( process_type . lower ( ) ) results . AddValue ( scalar . ScalarValue ( results . current_page , trace_name_for_process , 'count' , stats , important = False ) ) # Add temperature measurements. platform_info_utilization = self . _results . get ( 'platform_info' , { } ) board_temperature_c = platform_info_utilization . get ( 'average_temperature_c' ) if board_temperature_c is not None : results . AddValue ( scalar . ScalarValue ( results . current_page , 'board_temperature' , 'celsius' , board_temperature_c , important = False ) ) # Add CPU frequency measurements. frequency_hz = platform_info_utilization . get ( 'frequency_percent' ) if frequency_hz is not None : frequency_sum = 0.0 for freq , percent in frequency_hz . iteritems ( ) : frequency_sum += freq * ( percent / 100.0 ) results . AddValue ( scalar . ScalarValue ( results . current_page , 'cpu_average_frequency_hz' , 'Hz' , frequency_sum , important = False ) ) # Add CPU c-state residency measurements. cstate_percent = platform_info_utilization . get ( 'cstate_residency_percent' ) if cstate_percent is not None : for state , percent in cstate_percent . iteritems ( ) : results . AddValue ( scalar . ScalarValue ( results . current_page , 'cpu_cstate_%s_residency_percent' % state , '%' , percent , important = False ) ) self . _results = None