This commit is contained in:
2026-01-17 01:21:39 +03:00
parent 6aa6b0f179
commit 2e5b19f4d8
6 changed files with 282 additions and 5 deletions
+29
View File
@@ -1,5 +1,8 @@
__all__ = [
"get_time_of_pre_cycle_setup",
"get_time_of_validate_routers_for_collisions",
"get_time_of_most_similar_command",
"get_time_of_finds_appropriate_handler",
"attempts_to_average",
"run_benchmark",
"run_all_benchmarks",
@@ -16,6 +19,8 @@ from contextlib import redirect_stdout
from decimal import ROUND_HALF_UP, Decimal
from argenta import App
from argenta.router import Router
from argenta.command.models import InputCommand
from .models import Benchmark, BenchmarkResult, Benchmarks
@@ -26,6 +31,30 @@ def get_time_of_pre_cycle_setup(app: App) -> float:
end = time.perf_counter()
return (end - start) * 1000 # as milliseconds
def get_time_of_validate_routers_for_collisions(app: App) -> float:
app._setup_system_router() # pyright: ignore[reportPrivateUsage]
start = time.perf_counter()
with redirect_stdout(io.StringIO()):
app._validate_routers_for_collisions() # pyright: ignore[reportPrivateUsage]
end = time.perf_counter()
return (end - start) * 1000
def get_time_of_most_similar_command(app: App, unknown_command: str) -> float:
start = time.perf_counter()
with redirect_stdout(io.StringIO()):
app._most_similar_command(unknown_command) # pyright: ignore[reportPrivateUsage]
end = time.perf_counter()
return (end - start) * 1000
def get_time_of_finds_appropriate_handler(router: "Router", input_command: "InputCommand") -> float:
start = time.perf_counter()
with redirect_stdout(io.StringIO()):
router.finds_appropriate_handler(input_command)
end = time.perf_counter()
return (end - start) * 1000
def get_kernel_version() -> dict[str, str]:
system = platform.system()