tools/perf/experimental/representative_perf_test_limit_adjuster/adjust_upper_limits.py
def RecalculateUpperLimits(data_point_count):
  """Recalculates the upper limits using the data of recent runs.

  This method replaces the existing JSON file which contains the upper limits
  used by representative perf tests if the changes of upper limits are
  significant.

  Args:
    data_point_count: The number of runs to use for recalculation.
  """
  with open(os.path.join(UPPER_LIMITS_DATA_DIR,
            'platform_specific_tags.json')) as tags_data:
    platform_specific_tags = json.load(tags_data)

  with open(
    os.path.join(
      UPPER_LIMITS_DATA_DIR,
      'representatives_frame_times_upper_limit.json')) as current_data:
    current_upper_limits = json.load(current_data)

  max_change = 0.0
  results = {}
  for platform in platform_specific_tags:
    platform_data = platform_specific_tags[platform]
    print('\n- Processing data ({})'.format(platform))

    dataframe = CreateDataframe(platform_data['benchmark'],
                                platform_data['tags'], data_point_count)
    results[platform] = GetPercentileValues(dataframe, 0.95)

    # Loop over results and adjust base on current values.
    for story in results[platform]:
      if story in current_upper_limits[platform]:
        print(story, ':')
        new_avg, max_change = MeasureNewUpperLimit(
          current_upper_limits[platform][story]['avg'],
          results[platform][story]['avg'], 'AVG', max_change)
        results[platform][story]['avg'] = new_avg

        new_ci, max_change = MeasureNewUpperLimit(
          current_upper_limits[platform][story]['ci_095'],
          results[platform][story]['ci_095'], 'CI', max_change)
        results[platform][story]['ci_095'] = new_ci

        new_cpu_ratio, max_change = MeasureNewUpperLimit(
            current_upper_limits[platform][story]['cpu_wall_time_ratio'],
            results[platform][story]['cpu_wall_time_ratio'],
            'CPU_wall_time_ratio', max_change)
        results[platform][story]['cpu_wall_time_ratio'] = new_cpu_ratio

        if current_upper_limits[platform][story].get('control', False):
          results[platform][story]['control'] = True
        if current_upper_limits[platform][story].get('experimental', False):
          results[platform][story]['experimental'] = True
        comment = current_upper_limits[platform][story].get('_comment', False)
        if not comment == False:
          results[platform][story]['_comment'] = comment

  if max_change > CHANGE_PERCENTAGE_LIMIT:
    with open(
      os.path.join(
        UPPER_LIMITS_DATA_DIR,
        'representatives_frame_times_upper_limit.json'
      ), 'w') as outfile:
      json.dump(results, outfile, separators=(',', ': '), indent=2)
    print(
      'Upper limits were updated on '
      'representatives_frame_times_upper_limit.json')
  else:
    print('Changes are small, no need for new limits')
Recalculates the upper limits using the data of recent runs.

  This method replaces the existing JSON file which contains the upper limits
  used by representative perf tests if the changes of upper limits are
  significant.

  Args:
    data_point_count: The number of runs to use for recalculation.
  
Recalculates the upper limits using the data of recent runs.
This method replaces the existing JSON file which contains the upper limits
used by representative perf tests if the changes of upper limits are
significant.
Recalculates the upper limits using the data of recent runs . This method replaces the existing JSON file which contains the upper limits used by representative perf tests if the changes of upper limits are significant .
def RecalculateUpperLimits(data_point_count):
  with open(os.path.join(UPPER_LIMITS_DATA_DIR,
            'platform_specific_tags.json')) as tags_data:
    platform_specific_tags = json.load(tags_data)
  with open(
    os.path.join(
      UPPER_LIMITS_DATA_DIR,
      'representatives_frame_times_upper_limit.json')) as current_data:
    current_upper_limits = json.load(current_data)
  max_change = 0.0
  results = {}
  for platform in platform_specific_tags:
    platform_data = platform_specific_tags[platform]
    print('\n- Processing data ({})'.format(platform))
    dataframe = CreateDataframe(platform_data['benchmark'],
                                platform_data['tags'], data_point_count)
    results[platform] = GetPercentileValues(dataframe, 0.95)
    for story in results[platform]:
      if story in current_upper_limits[platform]:
        print(story, ':')
        new_avg, max_change = MeasureNewUpperLimit(
          current_upper_limits[platform][story]['avg'],
          results[platform][story]['avg'], 'AVG', max_change)
        results[platform][story]['avg'] = new_avg
        new_ci, max_change = MeasureNewUpperLimit(
          current_upper_limits[platform][story]['ci_095'],
          results[platform][story]['ci_095'], 'CI', max_change)
        results[platform][story]['ci_095'] = new_ci
        new_cpu_ratio, max_change = MeasureNewUpperLimit(
            current_upper_limits[platform][story]['cpu_wall_time_ratio'],
            results[platform][story]['cpu_wall_time_ratio'],
            'CPU_wall_time_ratio', max_change)
        results[platform][story]['cpu_wall_time_ratio'] = new_cpu_ratio
        if current_upper_limits[platform][story].get('control', False):
          results[platform][story]['control'] = True
        if current_upper_limits[platform][story].get('experimental', False):
          results[platform][story]['experimental'] = True
        comment = current_upper_limits[platform][story].get('_comment', False)
        if not comment == False:
          results[platform][story]['_comment'] = comment
  if max_change > CHANGE_PERCENTAGE_LIMIT:
    with open(
      os.path.join(
        UPPER_LIMITS_DATA_DIR,
        'representatives_frame_times_upper_limit.json'
      ), 'w') as outfile:
      json.dump(results, outfile, separators=(',', ': '), indent=2)
    print(
      'Upper limits were updated on '
      'representatives_frame_times_upper_limit.json')
  else:
    print('Changes are small, no need for new limits')
def RecalculateUpperLimits ( data_point_count ) : with open ( os . path . join ( UPPER_LIMITS_DATA_DIR , 'platform_specific_tags.json' ) ) as tags_data : platform_specific_tags = json . load ( tags_data ) with open ( os . path . join ( UPPER_LIMITS_DATA_DIR , 'representatives_frame_times_upper_limit.json' ) ) as current_data : current_upper_limits = json . load ( current_data ) max_change = 0.0 results = { } for platform in platform_specific_tags : platform_data = platform_specific_tags [ platform ] print ( '\n- Processing data ({})' . format ( platform ) ) dataframe = CreateDataframe ( platform_data [ 'benchmark' ] , platform_data [ 'tags' ] , data_point_count ) results [ platform ] = GetPercentileValues ( dataframe , 0.95 ) for story in results [ platform ] : if story in current_upper_limits [ platform ] : print ( story , ':' ) new_avg , max_change = MeasureNewUpperLimit ( current_upper_limits [ platform ] [ story ] [ 'avg' ] , results [ platform ] [ story ] [ 'avg' ] , 'AVG' , max_change ) results [ platform ] [ story ] [ 'avg' ] = new_avg new_ci , max_change = MeasureNewUpperLimit ( current_upper_limits [ platform ] [ story ] [ 'ci_095' ] , results [ platform ] [ story ] [ 'ci_095' ] , 'CI' , max_change ) results [ platform ] [ story ] [ 'ci_095' ] = new_ci new_cpu_ratio , max_change = MeasureNewUpperLimit ( current_upper_limits [ platform ] [ story ] [ 'cpu_wall_time_ratio' ] , results [ platform ] [ story ] [ 'cpu_wall_time_ratio' ] , 'CPU_wall_time_ratio' , max_change ) results [ platform ] [ story ] [ 'cpu_wall_time_ratio' ] = new_cpu_ratio if current_upper_limits [ platform ] [ story ] . get ( 'control' , False ) : results [ platform ] [ story ] [ 'control' ] = True if current_upper_limits [ platform ] [ story ] . get ( 'experimental' , False ) : results [ platform ] [ story ] [ 'experimental' ] = True comment = current_upper_limits [ platform ] [ story ] . get ( '_comment' , False ) if not comment == False : results [ platform ] [ story ] [ '_comment' ] = comment if max_change > CHANGE_PERCENTAGE_LIMIT : with open ( os . path . join ( UPPER_LIMITS_DATA_DIR , 'representatives_frame_times_upper_limit.json' ) , 'w' ) as outfile : json . dump ( results , outfile , separators = ( ',' , ': ' ) , indent = 2 ) print ( 'Upper limits were updated on ' 'representatives_frame_times_upper_limit.json' ) else : print ( 'Changes are small, no need for new limits' )
Recalculates the upper limits using the data of recent runs.
Recalculates the upper limits using the data of recent runs .
"""Recalculates the upper limits using the data of recent runs.

  This method replaces the existing JSON file which contains the upper limits
  used by representative perf tests if the changes of upper limits are
  significant.

  Args:
    data_point_count: The number of runs to use for recalculation.
  """ # Loop over results and adjust base on current values.
data_point_count
The number of runs to use for recalculation.
The number of runs to use for recalculation .