Repository: dotnet/runtime
File: src/coreclr/scripts/superpmi_collect_setup.py (Python)

Code before:
    print('Partitioning files from {0} to {1}'.format(src_directory, dst_directory))
    sorted_by_size = get_files_sorted_by_size(src_directory, exclude_directories, exclude_files)
    partitions = first_fit(sorted_by_size, max_size)

    index = 0
    for p_index in partitions:
        file_names = [curr_file[0] for curr_file in partitions[p_index]]
        curr_dst_path = os.path.join(dst_directory, str(index), "binaries")
        copy_files(src_directory, curr_dst_path, file_names)
        index += 1


def setup_benchmark(workitem_directory, arch):
    """ Perform setup of microbenchmarks/realworld

    Args:
        workitem_directory (string): Path to work
        arch (string): Architecture for which dotnet will be installed
    """
    performance_directory = os.path.join(workitem_directory, "performance")

    run_command(
        ["git", "clone", "--quiet", "--depth", "1", "https://github.com/adamperlin/performance", performance_directory])

    try:
        shutil.rmtree(os.path.join(performance_directory, ".git"))
    except Exception as ex:
        print("Warning: failed to remove directory \"%s\": %s", os.path.join(performance_directory, ".git"), ex)

def get_python_name():
    """Gets the python name

    Returns:
        [string]: Returns the appropriate python name depending on the OS.
    """
    if is_windows:
        return ["py", "-3"]
    else:
        return ["python3"]


def main(main_args):
    """ Main entrypoint

    Args:
        main_args ([type]): Arguments to the script
    """
    coreclr_args = setup_args(main_args)
    source_directory = coreclr_args.source_directory

    # If the payload directory doesn't already exist (it probably shouldn't) then create it.

Review comment (performance):
Technically, we also don't need to do `git clone` for dotnet/performance here and do that on the helix job machine, but it's fine to keep as is.

Code after:
    print('Partitioning files from {0} to {1}'.format(src_directory, dst_directory))
    sorted_by_size = get_files_sorted_by_size(src_directory, exclude_directories, exclude_files)
    partitions = first_fit(sorted_by_size, max_size)

    index = 0
    for p_index in partitions:
        file_names = [curr_file[0] for curr_file in partitions[p_index]]
        curr_dst_path = os.path.join(dst_directory, str(index), "binaries")
        copy_files(src_directory, curr_dst_path, file_names)
        index += 1


def setup_benchmark(workitem_directory, arch):
    """ Perform setup of microbenchmarks/realworld

    Args:
        workitem_directory (string): Path to work
        arch (string): Architecture for which dotnet will be installed
    """
    performance_directory = os.path.join(workitem_directory, "performance")

    run_command(
        ["git", "clone", "--quiet", "--depth", "1", "https://github.com/dotnet/performance", performance_directory])

    try:
        shutil.rmtree(os.path.join(performance_directory, ".git"))
    except Exception as ex:
        print("Warning: failed to remove directory \"%s\": %s", os.path.join(performance_directory, ".git"), ex)

def get_python_name():
    """Gets the python name

    Returns:
        [string]: Returns the appropriate python name depending on the OS.
    """
    if is_windows:
        return ["py", "-3"]
    else:
        return ["python3"]


def main(main_args):
    """ Main entrypoint

    Args:
        main_args ([type]): Arguments to the script
    """
    coreclr_args = setup_args(main_args)
    source_directory = coreclr_args.source_directory

    # If the payload directory doesn't already exist (it probably shouldn't) then create it.