This commit is contained in:
2026-01-18 23:53:52 +03:00
parent e7d064908f
commit 9d250fde9c
5 changed files with 158 additions and 168 deletions
+9 -47
View File
@@ -1,16 +1,12 @@
import platform
import cpuinfo
from rich.console import Console
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from argenta.command.models import Command
from argenta.response import Response
from argenta.router import Router
from .benchmarks.core.models import BenchmarkGroupResult
from .benchmarks.entity import benchmarks as registered_benchmarks
from .services.report_generator import ReportGenerator
from .services.system_info_reader import get_system_info
console = Console()
router = Router(title="Metrics commands:")
@@ -18,48 +14,14 @@ router = Router(title="Metrics commands:")
@router.command(Command("all-print", description="Print all benchmarks results"))
def all_print_handler(_: Response) -> None:
cpu_info = cpuinfo.get_cpu_info()
gpu_info = get_gpu_info()
os_info = get_kernel_version()
table = Table(show_header=True, header_style="bold cyan", border_style="blue", show_lines=True)
table.add_column("Parameter", style="green")
table.add_column("Value", style="yellow")
table.add_row("OS", platform.system())
table.add_row("OS Name", os_info['product_name'])
table.add_row("OS Kernel Version", os_info['kernel_version'])
table.add_row("Architecture", cpu_info['arch'])
table.add_row("CPU", cpu_info['brand_raw'])
table.add_row("GPU", gpu_info)
table.add_row("Python Version", cpu_info['python_version'])
table.add_row("Python Implementation", platform.python_implementation())
header_text = Text("SYSTEM INFO", style="bold magenta")
console.print(Panel(header_text, expand=False, border_style="magenta"))
console.print(table, end="\n\n")
report_generator = ReportGenerator(get_system_info())
console.print(report_generator.generate_system_info_header())
console.print(report_generator.generate_system_info_table())
return
type_grouped_benchmarks: list[BenchmarkGroupResult] = registered_benchmarks.run_benchmarks_grouped_by_type()
for results in type_grouped_benchmarks:
header_text = Text(f"TYPE: {results.type_.upper()} ; ITERATIONS: {results.iterations} ; ALL TIME IN MS", style="bold magenta")
console.print(Panel(header_text, expand=False, border_style="magenta"))
table = Table(show_header=True, header_style="bold cyan", border_style="blue", show_lines=True)
table.add_column("Description", style="dim")
table.add_column("Avg Time", justify="right", style="bold yellow")
table.add_column("Median Time", justify="right", style="bold yellow")
table.add_column("Stdev", justify="right", style="bold yellow")
for benchmark in results.benchmark_results:
table.add_row(
benchmark.description,
str(benchmark.avg_time),
str(benchmark.median_time),
str(benchmark.std_dev),
)
console.print(table)
for benchmark_group_result in type_grouped_benchmarks:
console.print(report_generator.generate_benchmark_table_header(benchmark_group_result))
console.print(report_generator.generate_benchmark_report_table(benchmark_group_result))
@router.command(Command("release-generate", description="Generate release report"))