def pretty_print_table()

in perfrunbook/utilities/measure_aggregated_pmu_stats.py [0:0]


def pretty_print_table(counter_table):
    """
    Takes a table of calculated counter ratios and percentiles and
    prints them in a formatted table for viewing.
    """
    ratios = [key for key in counter_table.keys()]
    stats = [key for key in counter_table[ratios[0]].keys()]

    hdr_string = f"|{'Ratio':<20}|"
    for stat in stats:
        hdr_string += f"{stat:>10}|"

    print(hdr_string)
    for ratio in ratios:
        line = f"|{ratio:<20}|"
        for stat in stats:
            line += f"{counter_table[ratio][stat]:>10.2f}|"
        print(line)