mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
bench
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ from argenta.app import StaticDividingLine
|
||||
|
||||
from .handlers import router
|
||||
|
||||
app = App(initial_message="metrics", prompt=">>> ", dividing_line=StaticDividingLine('~', length=70))
|
||||
app = App(initial_message="metrics", prompt=">>> ", dividing_line=None)
|
||||
orchestrator = Orchestrator()
|
||||
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ class Benchmarks:
|
||||
benchmark_results=benchmark_results
|
||||
)
|
||||
|
||||
def run_benchmarks_grouped_by_type(self) -> list[BenchmarkGroupResult]:
|
||||
def run_benchmarks_grouped_by_type(self, iterations: int = 100, is_gc_disabled: bool = False) -> list[BenchmarkGroupResult]:
|
||||
results: list[BenchmarkGroupResult] = []
|
||||
for type_, benchmarks in self._benchmarks_grouped_by_type.items():
|
||||
results.append(self.run_benchmarks_by_type(type_))
|
||||
results.append(self.run_benchmarks_by_type(type_, iterations, is_gc_disabled))
|
||||
return results
|
||||
|
||||
def get_benchmarks_by_type(self, type_: str) -> list[Benchmark]:
|
||||
|
||||
+10
-3
@@ -1,5 +1,6 @@
|
||||
from rich.console import Console
|
||||
|
||||
from argenta.command import Flag, PossibleValues
|
||||
from argenta.command.models import Command
|
||||
from argenta.response import Response
|
||||
from argenta.router import Router
|
||||
@@ -12,13 +13,19 @@ console = Console()
|
||||
router = Router(title="Metrics commands:")
|
||||
|
||||
|
||||
@router.command(Command("all-print", description="Print all benchmarks results"))
|
||||
@router.command(
|
||||
Command(
|
||||
"all-print",
|
||||
description="Print all benchmarks results",
|
||||
flags=Flag('without-gc', possible_values=PossibleValues.NEITHER)
|
||||
)
|
||||
)
|
||||
def all_print_handler(_: Response) -> None:
|
||||
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()
|
||||
is_gc_disabled = _.input_flags.get_flag_by_name("without-gc")
|
||||
type_grouped_benchmarks: list[BenchmarkGroupResult] = registered_benchmarks.run_benchmarks_grouped_by_type(is_gc_disabled=is_gc_disabled)
|
||||
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))
|
||||
|
||||
@@ -36,6 +36,7 @@ class ReportGenerator:
|
||||
def generate_benchmark_table_header(benchmark_group_result: BenchmarkGroupResult) -> Panel:
|
||||
header_text = Text(f"TYPE: {benchmark_group_result.type_.upper()} ; "
|
||||
f"ITERATIONS: {benchmark_group_result.iterations} ; "
|
||||
f"GC {"DISABLED" if benchmark_group_result.is_gc_disabled else "ENABLED"} ; "
|
||||
f"ALL TIME IN MS",
|
||||
style="bold magenta")
|
||||
return Panel(header_text, expand=False, border_style="magenta")
|
||||
@@ -55,8 +56,6 @@ class ReportGenerator:
|
||||
table.add_row("CPU Physical Cores", str(self.system_info.cpu_info.physical_cores))
|
||||
table.add_row("CPU Logical Cores", str(self.system_info.cpu_info.logical_cores))
|
||||
table.add_row("CPU Max Frequency", str(self.system_info.cpu_info.max_frequency) + ' GHz')
|
||||
table.add_row("CPU Min Frequency", str(self.system_info.cpu_info.min_frequency) + ' GHz')
|
||||
table.add_row("CPU Current Frequency", str(self.system_info.cpu_info.current_frequency) + ' GHz')
|
||||
table.add_row("Total RAM", str(self.system_info.memory_info.total_ram) + ' GB')
|
||||
table.add_row("Used RAM", str(self.system_info.memory_info.used_ram) + ' GB')
|
||||
table.add_row("Available RAM", str(self.system_info.memory_info.available_ram) + ' GB')
|
||||
|
||||
@@ -30,8 +30,6 @@ class CPUInfo:
|
||||
physical_cores: int
|
||||
logical_cores: int
|
||||
max_frequency: float
|
||||
min_frequency: float
|
||||
current_frequency: float
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class MemoryInfo:
|
||||
@@ -93,8 +91,6 @@ def get_cpu_info() -> CPUInfo:
|
||||
cpu_logical_cores = psutil.cpu_count(logical=True)
|
||||
|
||||
cpu_freq = psutil.cpu_freq() or "N/A"
|
||||
cpu_current_frequency = cpu_freq.current
|
||||
cpu_min_frequency = cpu_freq.min
|
||||
cpu_max_frequency = cpu_freq.max
|
||||
|
||||
return CPUInfo(
|
||||
@@ -102,8 +98,6 @@ def get_cpu_info() -> CPUInfo:
|
||||
architecture=cpu_architecture,
|
||||
physical_cores=cpu_physical_cores,
|
||||
logical_cores=cpu_logical_cores,
|
||||
current_frequency=cpu_current_frequency,
|
||||
min_frequency=cpu_min_frequency,
|
||||
max_frequency=cpu_max_frequency
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user