mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
ruff format
This commit is contained in:
@@ -3,7 +3,7 @@ __all__ = [
|
||||
"benchmark_many_commands_most_similar",
|
||||
"benchmark_many_aliases",
|
||||
"benchmark_partial_match",
|
||||
"benchmark_extreme_commands"
|
||||
"benchmark_extreme_commands",
|
||||
]
|
||||
|
||||
from argenta import App
|
||||
@@ -19,9 +19,11 @@ def setup_app_with_commands(command_count: int, aliases_per_command: int = 0) ->
|
||||
router = Router()
|
||||
|
||||
for i in range(command_count):
|
||||
aliases = {f'alias{i}_{j}' for j in range(aliases_per_command)} if aliases_per_command else set()
|
||||
aliases = (
|
||||
{f"alias{i}_{j}" for j in range(aliases_per_command)} if aliases_per_command else set()
|
||||
)
|
||||
|
||||
@router.command(Command(f'command{i}', aliases=aliases))
|
||||
@router.command(Command(f"command{i}", aliases=aliases))
|
||||
def handler(_res: Response) -> None:
|
||||
pass
|
||||
|
||||
@@ -29,31 +31,41 @@ def setup_app_with_commands(command_count: int, aliases_per_command: int = 0) ->
|
||||
return app
|
||||
|
||||
|
||||
@benchmarks.register(type_="most_similar_command", description="Few commands (10 commands, no match)")
|
||||
@benchmarks.register(
|
||||
type_="most_similar_command", description="Few commands (10 commands, no match)"
|
||||
)
|
||||
def benchmark_few_commands() -> None:
|
||||
app = setup_app_with_commands(10)
|
||||
app._most_similar_command("unknown")
|
||||
|
||||
|
||||
@benchmarks.register(type_="most_similar_command", description="Many commands (50 commands, no match)")
|
||||
@benchmarks.register(
|
||||
type_="most_similar_command", description="Many commands (50 commands, no match)"
|
||||
)
|
||||
def benchmark_many_commands_most_similar() -> None:
|
||||
app = setup_app_with_commands(50)
|
||||
app._most_similar_command("unknown")
|
||||
|
||||
|
||||
@benchmarks.register(type_="most_similar_command", description="Many aliases (20 commands, 10 aliases each)")
|
||||
@benchmarks.register(
|
||||
type_="most_similar_command", description="Many aliases (20 commands, 10 aliases each)"
|
||||
)
|
||||
def benchmark_many_aliases() -> None:
|
||||
app = setup_app_with_commands(20, aliases_per_command=10)
|
||||
app._most_similar_command("unknown")
|
||||
|
||||
|
||||
@benchmarks.register(type_="most_similar_command", description="Partial match (50 commands, prefix match)")
|
||||
@benchmarks.register(
|
||||
type_="most_similar_command", description="Partial match (50 commands, prefix match)"
|
||||
)
|
||||
def benchmark_partial_match() -> None:
|
||||
app = setup_app_with_commands(50)
|
||||
app._most_similar_command("comm")
|
||||
|
||||
|
||||
@benchmarks.register(type_="most_similar_command", description="Extreme (100 commands, 20 aliases each)")
|
||||
@benchmarks.register(
|
||||
type_="most_similar_command", description="Extreme (100 commands, 20 aliases each)"
|
||||
)
|
||||
def benchmark_extreme_commands() -> None:
|
||||
app = setup_app_with_commands(100, aliases_per_command=20)
|
||||
app._most_similar_command("comm")
|
||||
|
||||
Reference in New Issue
Block a user