tools/perf/process_perf_results.py
def _handle_perf_results(
    benchmark_enabled_map, benchmark_directory_map, configuration_name,
    build_properties, extra_links, output_results_dir):
  """
    Upload perf results to the perf dashboard.

    This method also upload the perf results to logdog and augment it to
    |extra_links|.

    Returns:
      (return_code, benchmark_upload_result_map)
      return_code is 0 if this upload to perf dashboard successfully, 1
        otherwise.
       benchmark_upload_result_map is a dictionary describes which benchmark
        was successfully uploaded.
  """
  begin_time = time.time()
  # Upload all eligible benchmarks to the perf dashboard
  results_dict = {}

  invocations = []
  for benchmark_name, directories in benchmark_directory_map.items():
    if not benchmark_enabled_map.get(benchmark_name, False):
      continue
    # Create a place to write the perf results that you will write out to
    # logdog.
    output_json_file = os.path.join(
        output_results_dir, (str(uuid.uuid4()) + benchmark_name))
    results_dict[benchmark_name] = output_json_file
    #TODO(crbug.com/1072729): pass final arguments instead of build properties
    # and configuration_name
    invocations.append((
        benchmark_name, directories, configuration_name,
        build_properties, output_json_file))

  # Kick off the uploads in multiple processes
  # crbug.com/1035930: We are hitting HTTP Response 429. Limit ourselves
  # to 2 processes to avoid this error. Uncomment the following code once
  # the problem is fixed on the dashboard side.
  # pool = multiprocessing.Pool(_GetCpuCount())
  pool = multiprocessing.Pool(2)
  upload_result_timeout = False
  try:
    async_result = pool.map_async(
        _upload_individual_benchmark, invocations)
    # TODO(crbug.com/947035): What timeout is reasonable?
    results = async_result.get(timeout=4000)
  except multiprocessing.TimeoutError:
    upload_result_timeout = True
    logging.error('Timeout uploading benchmarks to perf dashboard in parallel')
    results = []
    for benchmark_name in benchmark_directory_map:
      results.append((benchmark_name, False))
  finally:
    pool.terminate()

  # Keep a mapping of benchmarks to their upload results
  benchmark_upload_result_map = {}
  for r in results:
    benchmark_upload_result_map[r[0]] = r[1]

  logdog_dict = {}
  upload_failures_counter = 0
  logdog_stream = None
  logdog_label = 'Results Dashboard'
  for benchmark_name, output_file in results_dict.items():
    upload_succeed = benchmark_upload_result_map[benchmark_name]
    if not upload_succeed:
      upload_failures_counter += 1
    is_reference = '.reference' in benchmark_name
    _write_perf_data_to_logfile(
      benchmark_name, output_file,
      configuration_name, build_properties, logdog_dict,
      is_reference, upload_failure=not upload_succeed)

  logdog_file_name = _generate_unique_logdog_filename('Results_Dashboard_')
  logdog_stream = logdog_helper.text(logdog_file_name,
      json.dumps(dict(logdog_dict), sort_keys=True,
                  indent=4, separators=(',', ': ')),
      content_type=JSON_CONTENT_TYPE)
  if upload_failures_counter > 0:
    logdog_label += (' %s merge script perf data upload failures' %
                      upload_failures_counter)
  extra_links[logdog_label] = logdog_stream
  end_time = time.time()
  print_duration('Uploading results to perf dashboard', begin_time, end_time)
  if upload_result_timeout or upload_failures_counter > 0:
    return 1, benchmark_upload_result_map
  return 0, benchmark_upload_result_map

    Upload perf results to the perf dashboard.

    This method also upload the perf results to logdog and augment it to
    |extra_links|.

    Returns:
      (return_code, benchmark_upload_result_map)
      return_code is 0 if this upload to perf dashboard successfully, 1
        otherwise.
       benchmark_upload_result_map is a dictionary describes which benchmark
        was successfully uploaded.
  
Upload perf results to the perf dashboard.
This method also upload the perf results to logdog and augment it to
|extra_links|.
Upload perf results to the perf dashboard . This method also upload the perf results to logdog and augment it to |extra_links| .
def _handle_perf_results(
    benchmark_enabled_map, benchmark_directory_map, configuration_name,
    build_properties, extra_links, output_results_dir):
  begin_time = time.time()
  results_dict = {}
  invocations = []
  for benchmark_name, directories in benchmark_directory_map.items():
    if not benchmark_enabled_map.get(benchmark_name, False):
      continue
    output_json_file = os.path.join(
        output_results_dir, (str(uuid.uuid4()) + benchmark_name))
    results_dict[benchmark_name] = output_json_file
    invocations.append((
        benchmark_name, directories, configuration_name,
        build_properties, output_json_file))
  pool = multiprocessing.Pool(2)
  upload_result_timeout = False
  try:
    async_result = pool.map_async(
        _upload_individual_benchmark, invocations)
    results = async_result.get(timeout=4000)
  except multiprocessing.TimeoutError:
    upload_result_timeout = True
    logging.error('Timeout uploading benchmarks to perf dashboard in parallel')
    results = []
    for benchmark_name in benchmark_directory_map:
      results.append((benchmark_name, False))
  finally:
    pool.terminate()
  benchmark_upload_result_map = {}
  for r in results:
    benchmark_upload_result_map[r[0]] = r[1]
  logdog_dict = {}
  upload_failures_counter = 0
  logdog_stream = None
  logdog_label = 'Results Dashboard'
  for benchmark_name, output_file in results_dict.items():
    upload_succeed = benchmark_upload_result_map[benchmark_name]
    if not upload_succeed:
      upload_failures_counter += 1
    is_reference = '.reference' in benchmark_name
    _write_perf_data_to_logfile(
      benchmark_name, output_file,
      configuration_name, build_properties, logdog_dict,
      is_reference, upload_failure=not upload_succeed)
  logdog_file_name = _generate_unique_logdog_filename('Results_Dashboard_')
  logdog_stream = logdog_helper.text(logdog_file_name,
      json.dumps(dict(logdog_dict), sort_keys=True,
                  indent=4, separators=(',', ': ')),
      content_type=JSON_CONTENT_TYPE)
  if upload_failures_counter > 0:
    logdog_label += (' %s merge script perf data upload failures' %
                      upload_failures_counter)
  extra_links[logdog_label] = logdog_stream
  end_time = time.time()
  print_duration('Uploading results to perf dashboard', begin_time, end_time)
  if upload_result_timeout or upload_failures_counter > 0:
    return 1, benchmark_upload_result_map
  return 0, benchmark_upload_result_map
def _handle_perf_results ( benchmark_enabled_map , benchmark_directory_map , configuration_name , build_properties , extra_links , output_results_dir ) : begin_time = time . time ( ) results_dict = { } invocations = [ ] for benchmark_name , directories in benchmark_directory_map . items ( ) : if not benchmark_enabled_map . get ( benchmark_name , False ) : continue output_json_file = os . path . join ( output_results_dir , ( str ( uuid . uuid4 ( ) ) + benchmark_name ) ) results_dict [ benchmark_name ] = output_json_file invocations . append ( ( benchmark_name , directories , configuration_name , build_properties , output_json_file ) ) pool = multiprocessing . Pool ( 2 ) upload_result_timeout = False try : async_result = pool . map_async ( _upload_individual_benchmark , invocations ) results = async_result . get ( timeout = 4000 ) except multiprocessing . TimeoutError : upload_result_timeout = True logging . error ( 'Timeout uploading benchmarks to perf dashboard in parallel' ) results = [ ] for benchmark_name in benchmark_directory_map : results . append ( ( benchmark_name , False ) ) finally : pool . terminate ( ) benchmark_upload_result_map = { } for r in results : benchmark_upload_result_map [ r [ 0 ] ] = r [ 1 ] logdog_dict = { } upload_failures_counter = 0 logdog_stream = None logdog_label = 'Results Dashboard' for benchmark_name , output_file in results_dict . items ( ) : upload_succeed = benchmark_upload_result_map [ benchmark_name ] if not upload_succeed : upload_failures_counter += 1 is_reference = '.reference' in benchmark_name _write_perf_data_to_logfile ( benchmark_name , output_file , configuration_name , build_properties , logdog_dict , is_reference , upload_failure = not upload_succeed ) logdog_file_name = _generate_unique_logdog_filename ( 'Results_Dashboard_' ) logdog_stream = logdog_helper . text ( logdog_file_name , json . dumps ( dict ( logdog_dict ) , sort_keys = True , indent = 4 , separators = ( ',' , ': ' ) ) , content_type = JSON_CONTENT_TYPE ) if upload_failures_counter > 0 : logdog_label += ( ' %s merge script perf data upload failures' % upload_failures_counter ) extra_links [ logdog_label ] = logdog_stream end_time = time . time ( ) print_duration ( 'Uploading results to perf dashboard' , begin_time , end_time ) if upload_result_timeout or upload_failures_counter > 0 : return 1 , benchmark_upload_result_map return 0 , benchmark_upload_result_map
Upload perf results to the perf dashboard.
Upload perf results to the perf dashboard .
"""
    Upload perf results to the perf dashboard.

    This method also upload the perf results to logdog and augment it to
    |extra_links|.

    Returns:
      (return_code, benchmark_upload_result_map)
      return_code is 0 if this upload to perf dashboard successfully, 1
        otherwise.
       benchmark_upload_result_map is a dictionary describes which benchmark
        was successfully uploaded.
  """ # Upload all eligible benchmarks to the perf dashboard # Create a place to write the perf results that you will write out to # logdog. #TODO(crbug.com/1072729): pass final arguments instead of build properties # and configuration_name # Kick off the uploads in multiple processes # crbug.com/1035930: We are hitting HTTP Response 429. Limit ourselves # to 2 processes to avoid this error. Uncomment the following code once # the problem is fixed on the dashboard side. # pool = multiprocessing.Pool(_GetCpuCount()) # TODO(crbug.com/947035): What timeout is reasonable? # Keep a mapping of benchmarks to their upload results
(return_code, benchmark_upload_result_map)
return_code is 0 if this upload to perf dashboard successfully, 1
otherwise.
benchmark_upload_result_map is a dictionary describes which benchmark
was successfully uploaded.
( return_code benchmark_upload_result_map ) return_code is 0 if this upload to perf dashboard successfully 1 otherwise . benchmark_upload_result_map is a dictionary describes which benchmark was successfully uploaded .
benchmark_enabled_map
benchmark_directory_map
configuration_name
build_properties
extra_links
output_results_dir