-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscale_test.py
More file actions
51 lines (43 loc) · 1.44 KB
/
scale_test.py
File metadata and controls
51 lines (43 loc) · 1.44 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
"""
Scale Test - Predicts performance at different document scales
"""
import json
import math
from pathlib import Path
def predict_performance():
"""Predict performance at different scales."""
print("Scale test - predictions based on current performance")
text
# Current performance with 12 documents
current = {
"documents": 12,
"naive_ms": 247.3,
"optimized_ms": 179.1,
"no_compromise_ms": 91.7
}
# Predictions
scales = [100, 1000, 10000, 100000]
predictions = []
for scale in scales:
# FAISS search scales logarithmically: O(log n)
# Naive scales linearly, optimized scales sub-linearly due to filtering
log_factor = math.log(scale) / math.log(current["documents"])
prediction = {
"documents": scale,
"naive_ms": current["naive_ms"] * (scale / current["documents"]) * 0.7, # Some optimization
"optimized_ms": current["optimized_ms"] * log_factor * 1.2,
"no_compromise_ms": current["no_compromise_ms"] * log_factor
}
prediction["speedup_vs_naive"] = prediction["naive_ms"] / prediction["no_compromise_ms"]
predictions.append(prediction)
# Save predictions
Path("data").mkdir(exist_ok=True)
with open("data/scalability_predictions.json", "w") as f:
json.dump({
"current": current,
"predictions": predictions
}, f, indent=2)
print("Predictions saved to data/scalability_predictions.json")
return predictions
if name == "main":
predict_performance()