__init__.py 645 B

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