def compare_stats(stats1, stats2):
    col_widths = (60, 30, 30)
    header_template, row_template = get_templates(col_widths)
    mem_cell_template = '{%:<7,.2%} ({numerator:.0f} / {denominator:.0f})'
    time_cell_template = '{%:<7,.2%} ({numerator:.2f} / {denominator:.2f})'
    print(header_template.format('App', 'Mem diff %', 'Time diff %'))

    def print_sep():
        print(header_template.format(*['-' * (width - 1) for width in col_widths]))

    print_sep()

    def get_stats_diff(slug, stat):
        stats_item1 = stats1[slug]
        if slug not in stats2:
            return 100

        stats_item2 = stats2[slug]
        diff = stats_item2[stat] - stats_item1[stat]
        percent = float(diff) / stats_item1[stat]
        return {
            '%': percent,
            'numerator': diff,
            'denominator': stats_item1[stat]
        }

    def get_all_diffs(name):
        return [get_stats_diff(slug, name) for slug in stats1]

    all_mem = get_all_diffs('mem')
    all_time = get_all_diffs('time')
    for slug, mem, time in zip(stats1.keys(), all_mem, all_time):
        print(row_template.format(
            slug,
            mem_cell_template.format(**mem),
            time_cell_template.format(**time)
        ))

    print_sep()
    print(row_template.format(
        'Average',
        mem_cell_template.format(**avg_dict(all_mem)),
        time_cell_template.format(**avg_dict(all_time)),
    ))
Verify service root endpoint.
dataset/ETHPy150Open dimagi/commcare-hq/app_builder_live_test/compare_perf_stats.py/compare_stats--crossover with--dataset/ETHPy150Open soccermetrics/soccermetrics-client-py/tests/test_endpoints.py/ClientEndpointTest.test_service_root