testing/merge_scripts/code_coverage/merge_lib.py
def _validate_and_convert_profraws(profraw_files,
                                   profdata_tool_path,
                                   sparse=False):
  """Validates and converts profraws to profdatas.

  For each given .profraw file in the input, this method first validates it by
  trying to convert it to an indexed .profdata file, and if the validation and
  conversion succeeds, the generated .profdata file will be included in the
  output, otherwise, won't.

  This method is mainly used to filter out invalid profraw files.

  Args:
    profraw_files: A list of .profraw paths.
    profdata_tool_path: The path to the llvm-profdata executable.
    sparse (bool): flag to indicate whether to run llvm-profdata with --sparse.
      Doc: https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-merge

  Returns:
    A tulple:
      A list of converted .profdata files of *valid* profraw files.
      A list of *invalid* profraw files.
      A list of profraw files that have counter overflows.
  """
  for profraw_file in profraw_files:
    if not profraw_file.endswith('.profraw'):
      raise RuntimeError('%r is expected to be a .profraw file.' % profraw_file)

  cpu_count = multiprocessing.cpu_count()
  counts = max(10, cpu_count - 5)  # Use 10+ processes, but leave 5 cpu cores.
  pool = multiprocessing.Pool(counts)
  output_profdata_files = multiprocessing.Manager().list()
  invalid_profraw_files = multiprocessing.Manager().list()
  counter_overflows = multiprocessing.Manager().list()

  for profraw_file in profraw_files:
    pool.apply_async(
        _validate_and_convert_profraw,
        (profraw_file, output_profdata_files, invalid_profraw_files,
         counter_overflows, profdata_tool_path, sparse))

  pool.close()
  pool.join()

  # Remove inputs, as they won't be needed and they can be pretty large.
  for input_file in profraw_files:
    os.remove(input_file)

  return list(output_profdata_files), list(invalid_profraw_files), list(
      counter_overflows)
Validates and converts profraws to profdatas.

  For each given .profraw file in the input, this method first validates it by
  trying to convert it to an indexed .profdata file, and if the validation and
  conversion succeeds, the generated .profdata file will be included in the
  output, otherwise, won't.

  This method is mainly used to filter out invalid profraw files.

  Args:
    profraw_files: A list of .profraw paths.
    profdata_tool_path: The path to the llvm-profdata executable.
    sparse (bool): flag to indicate whether to run llvm-profdata with --sparse.
      Doc: https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-merge

  Returns:
    A tulple:
      A list of converted .profdata files of *valid* profraw files.
      A list of *invalid* profraw files.
      A list of profraw files that have counter overflows.
  
Validates and converts profraws to profdatas.
For each given .profraw file in the input, this method first validates it by
trying to convert it to an indexed .profdata file, and if the validation and
conversion succeeds, the generated .profdata file will be included in the
output, otherwise, won't.

This method is mainly used to filter out invalid profraw files.
Validates and converts profraws to profdatas . For each given . profraw file in the input this method first validates it by trying to convert it to an indexed . profdata file and if the validation and conversion succeeds the generated . profdata file will be included in the output otherwise won ' t . This method is mainly used to filter out invalid profraw files .
def _validate_and_convert_profraws(profraw_files,
                                   profdata_tool_path,
                                   sparse=False):
  for profraw_file in profraw_files:
    if not profraw_file.endswith('.profraw'):
      raise RuntimeError('%r is expected to be a .profraw file.' % profraw_file)
  cpu_count = multiprocessing.cpu_count()
  counts = max(10, cpu_count - 5)  
  pool = multiprocessing.Pool(counts)
  output_profdata_files = multiprocessing.Manager().list()
  invalid_profraw_files = multiprocessing.Manager().list()
  counter_overflows = multiprocessing.Manager().list()
  for profraw_file in profraw_files:
    pool.apply_async(
        _validate_and_convert_profraw,
        (profraw_file, output_profdata_files, invalid_profraw_files,
         counter_overflows, profdata_tool_path, sparse))
  pool.close()
  pool.join()
  for input_file in profraw_files:
    os.remove(input_file)
  return list(output_profdata_files), list(invalid_profraw_files), list(
      counter_overflows)
def _validate_and_convert_profraws ( profraw_files , profdata_tool_path , sparse = False ) : for profraw_file in profraw_files : if not profraw_file . endswith ( '.profraw' ) : raise RuntimeError ( '%r is expected to be a .profraw file.' % profraw_file ) cpu_count = multiprocessing . cpu_count ( ) counts = max ( 10 , cpu_count - 5 ) pool = multiprocessing . Pool ( counts ) output_profdata_files = multiprocessing . Manager ( ) . list ( ) invalid_profraw_files = multiprocessing . Manager ( ) . list ( ) counter_overflows = multiprocessing . Manager ( ) . list ( ) for profraw_file in profraw_files : pool . apply_async ( _validate_and_convert_profraw , ( profraw_file , output_profdata_files , invalid_profraw_files , counter_overflows , profdata_tool_path , sparse ) ) pool . close ( ) pool . join ( ) for input_file in profraw_files : os . remove ( input_file ) return list ( output_profdata_files ) , list ( invalid_profraw_files ) , list ( counter_overflows )
Validates and converts profraws to profdatas.
Validates and converts profraws to profdatas .
"""Validates and converts profraws to profdatas.

  For each given .profraw file in the input, this method first validates it by
  trying to convert it to an indexed .profdata file, and if the validation and
  conversion succeeds, the generated .profdata file will be included in the
  output, otherwise, won't.

  This method is mainly used to filter out invalid profraw files.

  Args:
    profraw_files: A list of .profraw paths.
    profdata_tool_path: The path to the llvm-profdata executable.
    sparse (bool): flag to indicate whether to run llvm-profdata with --sparse.
      Doc: https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-merge

  Returns:
    A tulple:
      A list of converted .profdata files of *valid* profraw files.
      A list of *invalid* profraw files.
      A list of profraw files that have counter overflows.
  """ # Use 10+ processes, but leave 5 cpu cores. # Remove inputs, as they won't be needed and they can be pretty large.
A tulple:
A list of converted .profdata files of *valid* profraw files.
A list of *invalid* profraw files.
A list of profraw files that have counter overflows.
A tulple : A list of converted . profdata files of * valid * profraw files . A list of * invalid * profraw files . A list of profraw files that have counter overflows .
profraw_files
A list of .profraw paths.
A list of . profraw paths .
profdata_tool_path
The path to the llvm-profdata executable.
The path to the llvm - profdata executable .
sparse
flag to indicate whether to run llvm-profdata with --sparse.
flag to indicate whether to run llvm - profdata with -- sparse .