|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import shutil |
4 | | -from typing import Optional |
| 4 | +from typing import TYPE_CHECKING, Optional |
5 | 5 |
|
| 6 | +from rich.box import HORIZONTALS |
6 | 7 | from rich.console import Console |
7 | 8 | from rich.table import Table |
8 | 9 |
|
9 | 10 | from codeflash.cli_cmds.console import logger |
10 | 11 | from codeflash.code_utils.time_utils import humanize_runtime |
11 | | -from codeflash.models.models import BenchmarkDetail, BenchmarkKey, ProcessedBenchmarkInfo |
| 12 | +from codeflash.models.models import BenchmarkDetail, ProcessedBenchmarkInfo |
12 | 13 | from codeflash.result.critic import performance_gain |
13 | 14 |
|
| 15 | +if TYPE_CHECKING: |
| 16 | + from codeflash.models.models import BenchmarkKey |
| 17 | + |
14 | 18 |
|
15 | 19 | def validate_and_format_benchmark_table(function_benchmark_timings: dict[str, dict[BenchmarkKey, int]], |
16 | 20 | total_benchmark_timings: dict[BenchmarkKey, int]) -> dict[str, list[tuple[BenchmarkKey, float, float, float]]]: |
@@ -49,10 +53,10 @@ def print_benchmark_table(function_to_results: dict[str, list[tuple[BenchmarkKey |
49 | 53 | function_name = func_path.split(":")[-1] |
50 | 54 |
|
51 | 55 | # Create a table for this function |
52 | | - table = Table(title=f"Function: {function_name}", border_style="blue") |
53 | | - |
| 56 | + table = Table(title=f"Function: {function_name}", width=terminal_width, border_style="blue", box=HORIZONTALS) |
| 57 | + benchmark_col_width = max(int(terminal_width * 0.4), 40) |
54 | 58 | # Add columns - split the benchmark test into two columns |
55 | | - table.add_column("Benchmark Module Path", style="cyan", overflow="fold") |
| 59 | + table.add_column("Benchmark Module Path", width=benchmark_col_width, style="cyan", overflow="fold") |
56 | 60 | table.add_column("Test Function", style="magenta", overflow="fold") |
57 | 61 | table.add_column("Total Time (ms)", justify="right", style="green") |
58 | 62 | table.add_column("Function Time (ms)", justify="right", style="yellow") |
|
0 commit comments