scripts/benchmark/trainer-benchmark.py/process_results
def process_results(results, target_metric_key, report_metric_keys, base_variation, output_dir):

    df = pd.DataFrame(results)
    variation_key = "variation"
    diff_key = "diff_%"

    sentinel_value = nan
    if base_variation is not None and len(df[df[variation_key] == base_variation]):
        # this may still return nan
        sentinel_value = df.loc[df[variation_key] == base_variation][target_metric_key].item()
    if math.isnan(sentinel_value):
        # as a fallback, use the minimal value as the sentinel
        sentinel_value = df.loc[df[target_metric_key] != nan][target_metric_key].min()

    # create diff column if possible
    if not math.isnan(sentinel_value):
        df[diff_key] = df.apply(
            lambda r: round(100 * (r[target_metric_key] - sentinel_value) / sentinel_value)
            if not math.isnan(r[target_metric_key])
            else 0,
            axis="columns",
        )

    # re-order columns
    cols = [variation_key, target_metric_key, diff_key, *report_metric_keys]
    df = df.reindex(cols, axis="columns")  # reorder cols

    # capitalize
    df = df.rename(str.capitalize, axis="columns")

    # make the cols as narrow as possible
    df_github = df.rename(lambda c: c.replace("_", "<br>"), axis="columns")
    df_console = df.rename(lambda c: c.replace("_", "\n"), axis="columns")

    report = ["", "Copy between the cut-here-lines and paste as is to github or a forum"]
    report += ["----------8<-----------------8<--------"]
    report += ["*** Results:", df_github.to_markdown(index=False, floatfmt=".2f")]
    report += ["```"]
    report += ["*** Setup:", get_versions()]
    report += ["*** The benchmark command line was:", get_original_command()]
    report += ["```"]
    report += ["----------8<-----------------8<--------"]
    report += ["*** Results (console):", df_console.to_markdown(index=False, floatfmt=".2f")]

    print("\n\n".join(report))