repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | """ |
| #2 | BEAM Scale Benchmark — demonstrates recall stays flat as corpus grows. |
| #3 | Run: PYTHONPATH=. python tests/benchmark_beam_scale.py |
| #4 | """ |
| #5 | |
| #6 | import time |
| #7 | import tempfile |
| #8 | from pathlib import Path |
| #9 | |
| #10 | from mnemosyne.core.beam import BeamMemory |
| #11 | |
| #12 | |
| #13 | def benchmark(): |
| #14 | with tempfile.TemporaryDirectory() as tmpdir: |
| #15 | db_path = Path(tmpdir) / "scale.db" |
| #16 | beam = BeamMemory(session_id="scale", db_path=db_path) |
| #17 | |
| #18 | sizes = [100, 500, 1000, 2000] |
| #19 | print("🔍 BEAM Recall Latency vs Corpus Size") |
| #20 | print("-" * 50) |
| #21 | |
| #22 | cumulative = 0 |
| #23 | for size in sizes: |
| #24 | # Insert batch |
| #25 | print(f"Inserting batch to reach {size} episodic memories...") |
| #26 | t0 = time.time() |
| #27 | batch = size - cumulative |
| #28 | for i in range(batch): |
| #29 | beam.consolidate_to_episodic( |
| #30 | summary=f"Scale test item {cumulative + i}: concept {i % 100} in domain {(cumulative + i) % 10}", |
| #31 | source_wm_ids=[f"s{cumulative + i}"], |
| #32 | importance=0.5 |
| #33 | ) |
| #34 | insert_sec = time.time() - t0 |
| #35 | cumulative = size |
| #36 | print(f" Batch insert ({batch} items): {insert_sec:.1f}s") |
| #37 | |
| #38 | # Benchmark recall |
| #39 | queries = ["concept 42", "domain 7", "nonexistent xyz"] |
| #40 | for q in queries: |
| #41 | times = [] |
| #42 | for _ in range(10): |
| #43 | t0 = time.time() |
| #44 | results = beam.recall(q, top_k=5) |
| #45 | times.append((time.time() - t0) * 1000) |
| #46 | avg = sum(times) / len(times) |
| #47 | p95 = sorted(times)[int(len(times) * 0.95)] |
| #48 | print(f" Corpus={size:4d} | Query='{q[:20]:<20}' | {avg:.2f}ms avg | {p95:.2f}ms p95") |
| #49 | |
| #50 | ep_stats = beam.get_episodic_stats() |
| #51 | print(f"\n📊 Final episodic memory: {ep_stats['total']} items | vectors: {ep_stats['vectors']}") |
| #52 | |
| #53 | |
| #54 | if __name__ == "__main__": |
| #55 | benchmark() |
| #56 |