mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
benchs
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user