hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# Copyright (c) 2017, Intel Corporation.
#
# SPDX-License-Identifier: GPL-2.0-only
#
"""Build performance test library functions"""
 
def print_table(rows, row_fmt=None):
    """Print data table"""
    if not rows:
        return
    if not row_fmt:
        row_fmt = ['{:{wid}} '] * len(rows[0])
 
    # Go through the data to get maximum cell widths
    num_cols = len(row_fmt)
    col_widths = [0] * num_cols
    for row in rows:
        for i, val in enumerate(row):
            col_widths[i] = max(col_widths[i], len(str(val)))
 
    for row in rows:
        print(*[row_fmt[i].format(col, wid=col_widths[i]) for i, col in enumerate(row)])