Files
freemo 31472b5413
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 22s
CI / lint (pull_request) Successful in 3m20s
CI / quality (pull_request) Successful in 3m43s
CI / typecheck (pull_request) Successful in 3m58s
CI / security (pull_request) Successful in 4m8s
CI / integration_tests (pull_request) Successful in 9m33s
CI / unit_tests (pull_request) Successful in 10m12s
CI / docker (pull_request) Successful in 1m28s
CI / coverage (pull_request) Successful in 12m18s
CI / e2e_tests (pull_request) Successful in 19m51s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 15s
CI / helm (push) Successful in 22s
CI / lint (push) Successful in 3m18s
CI / quality (push) Successful in 3m41s
CI / typecheck (push) Successful in 3m57s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 4m10s
CI / unit_tests (push) Failing after 6m58s
CI / docker (push) Has been skipped
CI / integration_tests (push) Successful in 9m15s
CI / coverage (push) Successful in 12m26s
CI / e2e_tests (push) Successful in 23m11s
CI / status-check (push) Failing after 1s
CI / benchmark-publish (push) Successful in 28m31s
CI / benchmark-regression (pull_request) Successful in 54m53s
test(coverage): add Behave scenarios for 39 under-covered modules
Add Behave feature/step pairs that exercise uncovered branches across handlers, LSP, CLI, and service layers to reach the coverage gate.

ISSUES CLOSED: #1232
2026-03-31 21:47:12 +00:00

157 lines
5.5 KiB
Python

"""ASV benchmarks for UKO Layer 3 technology vocabulary operations.
Measures the performance of:
- build_detail_level_map with insertions (Python: 3 insertions, 15-level map)
- build_detail_level_map without insertions (TS/RS/Java: identity, 12-level map)
- resolve_detail_level lookups (direct hit, parent fallback)
- UKOVocabulary construction (frozen Pydantic model with nested tuples)
- ProvenanceInfo construction
Based on specification.md Layer 3 Technology-Specific Specializations.
"""
from __future__ import annotations
import sys
from datetime import UTC, datetime
from pathlib import Path
try:
from cleveragents.acms.uko.layer3_java import JAVA_DETAIL_LEVELS
from cleveragents.acms.uko.layer3_py import PYTHON_DETAIL_LEVELS
from cleveragents.acms.uko.layer3_rs import RUST_DETAIL_LEVELS
from cleveragents.acms.uko.layer3_ts import TYPESCRIPT_DETAIL_LEVELS
from cleveragents.acms.uko.vocabulary import (
OO_EFFECTIVE_LEVELS,
ProvenanceInfo,
UKOClass,
UKOVocabulary,
build_detail_level_map,
resolve_detail_level,
)
except ModuleNotFoundError:
src_path = str(Path(__file__).resolve().parents[1] / "src")
if src_path not in sys.path:
sys.path.insert(0, src_path)
from cleveragents.acms.uko.layer3_java import JAVA_DETAIL_LEVELS
from cleveragents.acms.uko.layer3_py import PYTHON_DETAIL_LEVELS
from cleveragents.acms.uko.layer3_rs import RUST_DETAIL_LEVELS
from cleveragents.acms.uko.layer3_ts import TYPESCRIPT_DETAIL_LEVELS
from cleveragents.acms.uko.vocabulary import (
OO_EFFECTIVE_LEVELS,
ProvenanceInfo,
UKOClass,
UKOVocabulary,
build_detail_level_map,
resolve_detail_level,
)
class BuildDetailLevelMapSuite:
"""Benchmark build_detail_level_map for Layer 3 maps."""
timeout = 60
def setup(self) -> None:
"""Prepare parent levels and insertions."""
self.oo_levels = OO_EFFECTIVE_LEVELS
self.py_insertions: tuple[tuple[str, int], ...] = (
("DECORATED_SIGNATURES", 6),
("TYPE_STUBS", 9),
("WITH_TESTS", 12),
)
self.empty_insertions: tuple[tuple[str, int], ...] = ()
def time_build_with_insertions(self) -> None:
"""Build Python 15-level map (3 insertions into 12 parents)."""
build_detail_level_map(self.oo_levels, self.py_insertions)
def time_build_identity(self) -> None:
"""Build identity map (no insertions -- TS/RS/Java pattern)."""
build_detail_level_map(self.oo_levels, self.empty_insertions)
def track_python_map_size(self) -> int:
"""Track number of levels in the Python effective map."""
return len(build_detail_level_map(self.oo_levels, self.py_insertions))
def track_identity_map_size(self) -> int:
"""Track number of levels in the identity map."""
return len(build_detail_level_map(self.oo_levels, self.empty_insertions))
class ResolveDetailLevelSuite:
"""Benchmark resolve_detail_level lookups."""
timeout = 60
def setup(self) -> None:
"""Prepare maps for resolution."""
self.py_levels = PYTHON_DETAIL_LEVELS
self.ts_levels = TYPESCRIPT_DETAIL_LEVELS
self.rs_levels = RUST_DETAIL_LEVELS
self.java_levels = JAVA_DETAIL_LEVELS
self.parent_levels = OO_EFFECTIVE_LEVELS
self.child_only_map: tuple[tuple[str, int], ...] = (("CHILD_ONLY", 0),)
def time_resolve_first_level(self) -> None:
"""Resolve MODULE_LISTING (first entry -- best case)."""
resolve_detail_level("MODULE_LISTING", self.py_levels)
def time_resolve_last_level(self) -> None:
"""Resolve WITH_TESTS (last entry -- worst case)."""
resolve_detail_level("WITH_TESTS", self.py_levels)
def time_resolve_inserted_level(self) -> None:
"""Resolve DECORATED_SIGNATURES (inserted level)."""
resolve_detail_level("DECORATED_SIGNATURES", self.py_levels)
def time_resolve_with_parent_fallback(self) -> None:
"""Resolve via parent fallback (name not in child map)."""
resolve_detail_level("MODULE_LISTING", self.child_only_map, self.parent_levels)
def time_resolve_ts(self) -> None:
"""Resolve SIGNATURES in TypeScript map."""
resolve_detail_level("SIGNATURES", self.ts_levels)
def time_resolve_rs(self) -> None:
"""Resolve SIGNATURES in Rust map."""
resolve_detail_level("SIGNATURES", self.rs_levels)
def time_resolve_java(self) -> None:
"""Resolve SIGNATURES in Java map."""
resolve_detail_level("SIGNATURES", self.java_levels)
class VocabularyConstructionSuite:
"""Benchmark UKOVocabulary and ProvenanceInfo construction."""
timeout = 60
def setup(self) -> None:
"""Pre-compute a fixed datetime to avoid syscall noise."""
self.fixed_datetime = datetime.now(tz=UTC)
def time_provenance_info(self) -> None:
"""Construct a ProvenanceInfo instance."""
ProvenanceInfo(
source_resource="res-01",
source_path="src/main.py",
valid_from=self.fixed_datetime,
)
def time_uko_class(self) -> None:
"""Construct a UKOClass instance."""
UKOClass(
uri="https://example.com/Test",
label="Test",
subclass_of=("https://example.com/Parent",),
)
def time_uko_vocabulary(self) -> None:
"""Construct a minimal UKOVocabulary instance."""
UKOVocabulary(
namespace="https://example.com/test#",
prefix="test:",
label="Test Vocabulary",
)