284d2a9f00
CI / quality (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 49s
CI / typecheck (pull_request) Successful in 50s
CI / build (pull_request) Successful in 50s
CI / security (pull_request) Successful in 55s
CI / integration_tests (pull_request) Successful in 59s
CI / unit_tests (pull_request) Successful in 3m38s
CI / coverage (pull_request) Successful in 3m35s
CI / status-check (pull_request) Successful in 4s
CI / lint (push) Successful in 33s
CI / quality (push) Successful in 58s
CI / typecheck (push) Successful in 1m1s
CI / security (push) Successful in 1m1s
CI / build (push) Successful in 52s
CI / integration_tests (push) Successful in 1m12s
CI / unit_tests (push) Successful in 3m41s
CI / coverage (push) Successful in 3m35s
CI / status-check (push) Successful in 3s
Extend TemplateType enum with TEMPLATE, SKILL, ACTOR, MCP, LSP. Add optional package_ref field to ComponentReference for registry references. Create ReferenceResolver with multi-server RegistryClient pool and caching. Update InstantiationContext for registry-aware resolution with _original_reference. Extend TemplateRegistry, EnhancedTemplateRegistry, and TemplateStore for 8 types. Add registry reference detection in instantiate_from_config. Add GenericTemplate for new package types without specialized template classes. ISSUES CLOSED: #27
94 lines
2.8 KiB
Python
94 lines
2.8 KiB
Python
"""ASV benchmarks for the Registry HTTP client.
|
|
|
|
Measures performance of the RegistryClient against a fake registry server
|
|
for the four API endpoints.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import json
|
|
from typing import Any
|
|
|
|
import httpx
|
|
|
|
from cleveractors.registry.client import RegistryClient
|
|
|
|
|
|
class RegistryClientBenchmark:
|
|
"""Benchmark suite for RegistryClient."""
|
|
|
|
params: list[str] = ["actor", "template", "skill"]
|
|
|
|
def setup(self, pkg_type: str = "") -> None:
|
|
self.client = RegistryClient(
|
|
base_url="http://127.0.0.1:9199",
|
|
timeout=5.0,
|
|
)
|
|
self.fake_package_id = "pkg_act_a1b2c3d4e5f67890abcdef1234567890abcdef"
|
|
|
|
def teardown(self, pkg_type: str = "") -> None:
|
|
async def _close() -> None:
|
|
await self.client.close()
|
|
|
|
try:
|
|
asyncio.get_event_loop().run_until_complete(_close())
|
|
except RuntimeError:
|
|
asyncio.run(_close())
|
|
|
|
def time_get_package(self, pkg_type: str = "") -> None:
|
|
async def _bench() -> None:
|
|
await self.client.get_package(self.fake_package_id)
|
|
|
|
try:
|
|
loop = asyncio.get_event_loop()
|
|
if loop.is_running():
|
|
future = asyncio.ensure_future(_bench(), loop=loop)
|
|
loop.run_until_complete(future)
|
|
else:
|
|
loop.run_until_complete(_bench())
|
|
except Exception:
|
|
pass
|
|
|
|
def time_resolve_package(self, pkg_type: str) -> None:
|
|
async def _bench() -> None:
|
|
await self.client.resolve_package(pkg_type, "example", "test", "v1.0.0")
|
|
|
|
try:
|
|
loop = asyncio.get_event_loop()
|
|
if loop.is_running():
|
|
future = asyncio.ensure_future(_bench(), loop=loop)
|
|
loop.run_until_complete(future)
|
|
else:
|
|
loop.run_until_complete(_bench())
|
|
except Exception:
|
|
pass
|
|
|
|
def time_browse(self, pkg_type: str = "") -> None:
|
|
async def _bench() -> None:
|
|
await self.client.browse()
|
|
|
|
try:
|
|
loop = asyncio.get_event_loop()
|
|
if loop.is_running():
|
|
future = asyncio.ensure_future(_bench(), loop=loop)
|
|
loop.run_until_complete(future)
|
|
else:
|
|
loop.run_until_complete(_bench())
|
|
except Exception:
|
|
pass
|
|
|
|
def time_discover(self, pkg_type: str = "") -> None:
|
|
async def _bench() -> None:
|
|
await self.client.discover()
|
|
|
|
try:
|
|
loop = asyncio.get_event_loop()
|
|
if loop.is_running():
|
|
future = asyncio.ensure_future(_bench(), loop=loop)
|
|
loop.run_until_complete(future)
|
|
else:
|
|
loop.run_until_complete(_bench())
|
|
except Exception:
|
|
pass
|