Skip to content

Commit 6100620

Browse files
committed
attempt to use horizontals for rows
1 parent 4d0eb3d commit 6100620

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

codeflash/benchmarking/utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
from __future__ import annotations
22

33
import shutil
4-
from typing import Optional
4+
from typing import TYPE_CHECKING, Optional
55

6+
from rich.box import HORIZONTALS
67
from rich.console import Console
78
from rich.table import Table
89

910
from codeflash.cli_cmds.console import logger
1011
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
1213
from codeflash.result.critic import performance_gain
1314

15+
if TYPE_CHECKING:
16+
from codeflash.models.models import BenchmarkKey
17+
1418

1519
def validate_and_format_benchmark_table(function_benchmark_timings: dict[str, dict[BenchmarkKey, int]],
1620
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
4953
function_name = func_path.split(":")[-1]
5054

5155
# 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)
5458
# 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")
5660
table.add_column("Test Function", style="magenta", overflow="fold")
5761
table.add_column("Total Time (ms)", justify="right", style="green")
5862
table.add_column("Function Time (ms)", justify="right", style="yellow")

0 commit comments

Comments
 (0)