Files
cleveragents-core/benchmarks/server_stub_bench.py
T
freemo 6519f140a9 feat(context): add hot/warm/cold tiers and actor views
Implement hot/warm/cold context tiers with ContextTier, ActorRole,
TieredFragment, TierBudget, ActorContextView, TierMetrics, and
ScopedBackendView models. ContextTierService provides store/get,
promotion/demotion with cold-tier summarisation hook, LRU eviction,
per-actor filtered views (strategist/executor/reviewer), and
project-scoped isolation via ScopedBackendView.

Settings: context_max_tokens_hot, context_max_decisions_warm,
context_max_decisions_cold. DI-wired as singleton context_tier_service.

Includes Behave BDD scenarios (30), Robot Framework integration tests (7),
ASV benchmarks (5 suites), and docs/reference/context_tiers.md.

Closes #208
2026-03-03 17:01:57 +00:00

88 lines
2.6 KiB
Python

"""ASV benchmarks for server client stubs and connection config.
Measures the performance of:
- ServerConnectionConfig construction and validation
- StubServerClient/StubRemoteExecutionClient/StubAuthClient instantiation
- Config key registry lookups for server.* keys
"""
from __future__ import annotations
import importlib
import sys
from pathlib import Path
# Ensure the local *source* tree is importable even when ASV has an
# older build of the package installed.
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
# Force-reload so ASV picks up the source tree version.
import cleveragents # noqa: E402
importlib.reload(cleveragents)
from cleveragents.acp.clients import ( # noqa: E402
StubAuthClient,
StubRemoteExecutionClient,
StubServerClient,
)
from cleveragents.acp.server_config import ServerConnectionConfig # noqa: E402
from cleveragents.application.services.config_service import _REGISTRY # noqa: E402
# ---------------------------------------------------------------------------
# Config resolution benchmarks
# ---------------------------------------------------------------------------
class ServerConfigResolutionSuite:
"""Benchmark ServerConnectionConfig construction overhead."""
timeout = 60
def time_create_config_minimal(self) -> None:
ServerConnectionConfig(server_url="https://agents.example.com")
def time_create_config_full(self) -> None:
ServerConnectionConfig(
server_url="https://agents.example.com",
namespace="my-team",
auth_token_ref="CLEVERAGENTS_SERVER_TOKEN",
tls_verify=False,
)
def time_registry_lookup_server_url(self) -> None:
_ = _REGISTRY["server.url"]
def time_registry_lookup_server_tls(self) -> None:
_ = _REGISTRY["server.tls-verify"]
def time_registry_lookup_server_namespace(self) -> None:
_ = _REGISTRY["server.namespace"]
# ---------------------------------------------------------------------------
# Stub client benchmarks
# ---------------------------------------------------------------------------
class StubClientInstantiationSuite:
"""Benchmark stub client instantiation overhead."""
timeout = 60
def time_instantiate_stub_server_client(self) -> None:
StubServerClient()
def time_instantiate_stub_execution_client(self) -> None:
StubRemoteExecutionClient()
def time_instantiate_stub_auth_client(self) -> None:
StubAuthClient()
def time_instantiate_all_stubs(self) -> None:
StubServerClient()
StubRemoteExecutionClient()
StubAuthClient()