-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathperformance_baseline.py
More file actions
executable file
·55 lines (41 loc) · 1.62 KB
/
performance_baseline.py
File metadata and controls
executable file
·55 lines (41 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# SPDX-FileCopyrightText: 2025 Knitli Inc.
# SPDX-FileContributor: Adam Poulemanos <adam@knit.li>
#
# SPDX-License-Identifier: MIT OR Apache-2.0
import asyncio
import logging
import time
from codeweaver.core import get_container
from codeweaver.engine import Indexer
from codeweaver.providers import EmbeddingProvider
# Suppress logging for cleaner output
logging.getLogger("codeweaver").setLevel(logging.ERROR)
async def benchmark_initialization() -> None:
print("--- Performance Baseline: Initialization ---")
start = time.perf_counter()
await Indexer.from_settings_async()
end = time.perf_counter()
print(f"Indexer.from_settings_async(): {(end - start) * 1000:.2f}ms")
container = get_container()
start = time.perf_counter()
await container.resolve(Indexer)
end = time.perf_counter()
print(f"Container.resolve(Indexer): {(end - start) * 1000:.2f}ms")
async def benchmark_embedding() -> None:
print("\n--- Performance Baseline: Embedding (Local/Mock) ---")
container = get_container()
try:
embedding = await container.resolve(EmbeddingProvider)
start = time.perf_counter()
# Simple short text
await embedding.embed_query("test code search")
end = time.perf_counter()
print(f"EmbeddingProvider.embed_query(): {(end - start) * 1000:.2f}ms")
except Exception as e:
print(f"Embedding benchmark skipped: {e}")
async def main() -> None:
await benchmark_initialization()
# Embedding might require API keys or local models, skip if not available
# await benchmark_embedding()
if __name__ == "__main__":
asyncio.run(main())