7153050211
CI / lint (pull_request) Successful in 24s
CI / quality (pull_request) Successful in 24s
CI / benchmark-publish (pull_request) Has been skipped
CI / typecheck (pull_request) Successful in 34s
CI / security (pull_request) Successful in 50s
CI / build (pull_request) Successful in 27s
CI / integration_tests (pull_request) Successful in 3m33s
CI / unit_tests (pull_request) Successful in 17m30s
CI / docker (pull_request) Successful in 1m1s
CI / benchmark-regression (pull_request) Successful in 19m12s
CI / coverage (pull_request) Successful in 29m22s
Adds cleveragents.acp package with seven modules: models (AcpMessage, AcpEnvelope, AcpCapability, AcpPeerInfo), errors (AcpError hierarchy), facade (AcpFacade with register/discover/send/receive), transport (AcpTransportBase, LoopbackTransport), events (AcpEventBus), and versioning (AcpVersion with compatible_with check). 44 Behave scenarios, 5 Robot smoke tests, ASV benchmark suite, and reference documentation. Ref: Day-14 Rebaseline – M6.1 ACP-facade stubs [Jeff]
125 lines
3.7 KiB
Python
125 lines
3.7 KiB
Python
"""ASV benchmarks for ACP facade dispatch, version negotiation, and event queue.
|
|
|
|
Measures the performance of:
|
|
- AcpLocalFacade dispatch overhead per operation
|
|
- AcpVersionNegotiator negotiation throughput
|
|
- AcpEventQueue publish and get_events throughput
|
|
"""
|
|
|
|
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.events import AcpEventQueue # noqa: E402
|
|
from cleveragents.acp.facade import AcpLocalFacade # noqa: E402
|
|
from cleveragents.acp.models import AcpEvent, AcpRequest # noqa: E402
|
|
from cleveragents.acp.versioning import AcpVersionNegotiator # noqa: E402
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Facade dispatch benchmarks
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
class FacadeDispatchSuite:
|
|
"""Benchmark AcpLocalFacade.dispatch() overhead."""
|
|
|
|
timeout = 60
|
|
|
|
def setup(self) -> None:
|
|
self.facade = AcpLocalFacade()
|
|
self.session_req = AcpRequest(operation="session.create")
|
|
self.plan_req = AcpRequest(
|
|
operation="plan.execute", params={"plan_id": "BENCH001"}
|
|
)
|
|
self.context_req = AcpRequest(operation="context.get")
|
|
|
|
def time_dispatch_session_create(self) -> None:
|
|
self.facade.dispatch(self.session_req)
|
|
|
|
def time_dispatch_plan_execute(self) -> None:
|
|
self.facade.dispatch(self.plan_req)
|
|
|
|
def time_dispatch_context_get(self) -> None:
|
|
self.facade.dispatch(self.context_req)
|
|
|
|
def time_dispatch_all_operations(self) -> None:
|
|
for op in self.facade.list_operations():
|
|
req = AcpRequest(operation=op)
|
|
self.facade.dispatch(req)
|
|
|
|
def time_list_operations(self) -> None:
|
|
self.facade.list_operations()
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Version negotiation benchmarks
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
class VersionNegotiationSuite:
|
|
"""Benchmark AcpVersionNegotiator throughput."""
|
|
|
|
timeout = 60
|
|
|
|
def setup(self) -> None:
|
|
self.negotiator = AcpVersionNegotiator()
|
|
|
|
def time_negotiate_supported(self) -> None:
|
|
self.negotiator.negotiate("1.0")
|
|
|
|
def time_is_supported_true(self) -> None:
|
|
self.negotiator.is_supported("1.0")
|
|
|
|
def time_is_supported_false(self) -> None:
|
|
self.negotiator.is_supported("99.0")
|
|
|
|
def time_get_current(self) -> None:
|
|
self.negotiator.get_current()
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Event queue benchmarks
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
class EventQueueSuite:
|
|
"""Benchmark AcpEventQueue throughput."""
|
|
|
|
timeout = 60
|
|
|
|
def setup(self) -> None:
|
|
self.queue = AcpEventQueue()
|
|
self.event = AcpEvent(event_type="bench.event")
|
|
|
|
def time_publish_single(self) -> None:
|
|
self.queue.publish(self.event)
|
|
|
|
def time_publish_100(self) -> None:
|
|
for _ in range(100):
|
|
self.queue.publish(self.event)
|
|
|
|
def time_get_events_default(self) -> None:
|
|
self.queue.get_events()
|
|
|
|
def time_subscribe_local(self) -> None:
|
|
self.queue.subscribe_local(lambda e: None)
|
|
|
|
def time_publish_with_subscriber(self) -> None:
|
|
q = AcpEventQueue()
|
|
q.subscribe_local(lambda e: None)
|
|
for _ in range(100):
|
|
q.publish(self.event)
|