Files
cleveragents-core/benchmarks/bench_detail_level_map.py
T
freemo c65e8a5285
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 16s
CI / lint (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 59s
CI / security (pull_request) Successful in 59s
CI / unit_tests (pull_request) Successful in 3m9s
CI / integration_tests (pull_request) Successful in 3m34s
CI / e2e_tests (pull_request) Successful in 3m54s
CI / docker (pull_request) Successful in 55s
CI / coverage (pull_request) Successful in 6m1s
CI / build (push) Successful in 15s
CI / lint (push) Successful in 16s
CI / quality (push) Successful in 27s
CI / typecheck (push) Successful in 38s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 48s
CI / unit_tests (push) Successful in 3m14s
CI / integration_tests (push) Successful in 3m30s
CI / docker (push) Successful in 56s
CI / e2e_tests (push) Successful in 4m43s
CI / coverage (push) Successful in 6m1s
CI / benchmark-publish (push) Successful in 19m50s
CI / benchmark-regression (pull_request) Successful in 37m17s
feat(resource): add cloud infrastructure resources
Implement cloud resource types (aws, gcp, azure) with credential
fields, region/tenant metadata, and stubbed sandbox strategies.
Credential resolution uses environment variables and profile names
with no secrets logged.

Key changes:
- Add CloudResourceHandler with aws/gcp/azure type definitions
- Add credential resolution from env vars and profile names
- Add stubbed sandbox strategies (validate config, raise NotImplementedError)
- Register cloud types in bootstrap_builtin_types
- Credential masking via existing redaction patterns
- Add Behave BDD tests, Robot integration tests, ASV benchmarks

ISSUES CLOSED: #343
2026-03-17 13:14:37 -04:00

143 lines
4.6 KiB
Python

"""ASV benchmarks for DetailLevelMap operations.
Measures the performance of DetailLevelMap operations including:
- Named level resolution (string lookups)
- Integer depth resolution (clamping)
- Effective level map computation (inheritance merge)
- DetailLevelMapBuilder insertions and build
- VocabularyRegistry lookups
Based on specification.md DetailDepth and DetailLevelMap sections.
"""
from __future__ import annotations
import sys
from pathlib import Path
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
from cleveragents.acms.uko.detail_level_maps import ( # noqa: E402
CODE_DETAIL_LEVEL_MAP,
OO_DETAIL_LEVEL_MAP,
DetailLevelMapBuilder,
build_effective_map,
)
from cleveragents.acms.uko.vocabularies import ( # noqa: E402
get_func_vocabulary,
get_oo_vocabulary,
get_proc_vocabulary,
)
from cleveragents.acms.uko.vocabulary_registry import VocabularyRegistry # noqa: E402
class DetailLevelMapResolutionSuite:
"""Benchmark DetailLevelMap.resolve() for named and integer depths."""
timeout = 60
def setup(self) -> None:
"""Prepare maps for benchmarking."""
self.code_map = CODE_DETAIL_LEVEL_MAP
self.oo_map = OO_DETAIL_LEVEL_MAP
def time_resolve_named_level_code(self) -> None:
"""Benchmark resolving a named level in the code map."""
self.code_map.resolve("SIGNATURES")
def time_resolve_named_level_oo(self) -> None:
"""Benchmark resolving a named level in the OO map."""
self.oo_map.resolve("CLASS_HIERARCHY")
def time_resolve_integer_depth(self) -> None:
"""Benchmark resolving an integer depth."""
self.code_map.resolve(4)
def time_resolve_integer_clamped(self) -> None:
"""Benchmark resolving an integer that exceeds max_depth."""
self.code_map.resolve(100)
def time_resolve_inherited_level(self) -> None:
"""Benchmark resolving a level inherited from parent."""
self.oo_map.resolve("MODULE_LISTING")
def time_effective_levels_code(self) -> None:
"""Benchmark computing effective levels for code map."""
self.code_map.effective_levels()
def time_effective_levels_oo(self) -> None:
"""Benchmark computing effective levels for OO map (with parent)."""
self.oo_map.effective_levels()
class DetailLevelMapBuilderSuite:
"""Benchmark DetailLevelMapBuilder operations."""
timeout = 60
def setup(self) -> None:
"""Prepare parent map."""
self.code_map = CODE_DETAIL_LEVEL_MAP
def time_build_with_single_insertion(self) -> None:
"""Benchmark building a map with one insertion."""
builder = DetailLevelMapBuilder(self.code_map, "bench:")
builder.insert_after("MEMBER_LISTING", "BENCH_LEVEL")
builder.build()
def time_build_with_two_insertions(self) -> None:
"""Benchmark building a map with two insertions (OO pattern)."""
builder = DetailLevelMapBuilder(self.code_map, "bench:")
builder.insert_after("MEMBER_LISTING", "BENCH_A")
builder.insert_after("SIGNATURES_WITH_DOCS", "BENCH_B")
builder.build()
def time_build_effective_map_no_insertions(self) -> None:
"""Benchmark build_effective_map with empty insertions."""
build_effective_map(self.code_map, [])
def time_build_effective_map_with_insertions(self) -> None:
"""Benchmark build_effective_map with two insertions."""
build_effective_map(
self.code_map,
[("MEMBER_LISTING", "X"), ("SIGNATURES_WITH_DOCS", "Y")],
)
class VocabularyRegistrySuite:
"""Benchmark VocabularyRegistry operations."""
timeout = 60
def setup(self) -> None:
"""Build and populate the registry."""
self.registry = VocabularyRegistry(
vocabularies=(
get_oo_vocabulary(),
get_func_vocabulary(),
get_proc_vocabulary(),
)
)
def time_get_by_prefix(self) -> None:
"""Benchmark looking up vocabulary by prefix."""
self.registry.get_by_prefix("uko-oo:")
def time_get_by_iri(self) -> None:
"""Benchmark looking up vocabulary by IRI."""
self.registry.get_by_iri("https://cleveragents.ai/ontology/uko/oo#")
def time_list_prefixes(self) -> None:
"""Benchmark listing all prefixes."""
self.registry.list_prefixes()
def time_list_all(self) -> None:
"""Benchmark listing all vocabularies."""
self.registry.list_all()
def time_contains_check(self) -> None:
"""Benchmark __contains__ check."""
_ = "uko-oo:" in self.registry