MCPcopy Create free account
hub / github.com/cosdata/cosdata / test_performance

Function test_performance

tests/test-performance.py:89–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89def test_performance():
90 # Get password from .env file or prompt securely
91 password = os.getenv("COSDATA_PASSWORD")
92 if not password:
93 password = getpass.getpass("Enter your database password: ")
94
95 # Initialize client
96 host = os.getenv("COSDATA_HOST", "http://127.0.0.1:8443")
97 username = os.getenv("COSDATA_USERNAME", "admin")
98 client = Client(host=host, username=username, password=password, verify=False)
99
100 # Test parameters
101 collection_name = "performance_test"
102 dimensions = 1024
103 perturbation_degree = 0.95
104 batch_size = 100
105 batch_count = 1000
106 num_workers = 32
107
108 try:
109 # Create collection
110 print("Creating collection...")
111 collection = client.create_collection(
112 name=collection_name,
113 dimension=dimensions,
114 description="Performance test collection",
115 )
116
117 # Create index
118 print("Creating index...")
119 collection.create_index(
120 distance_metric="cosine",
121 num_layers=7,
122 max_cache_size=1000,
123 ef_construction=512,
124 ef_search=256,
125 neighbors_count=32,
126 level_0_neighbors_count=64,
127 )
128
129 start_time = time.time()
130
131 # Generate vectors in parallel
132 print("Generating test vectors...")
133 test_vectors = []
134 with ThreadPoolExecutor(max_workers=num_workers) as executor:
135 futures = []
136 for base_idx in range(batch_count):
137 futures.append(
138 executor.submit(
139 generate_batch,
140 base_idx,
141 batch_size,
142 dimensions,
143 perturbation_degree,
144 )
145 )
146

Callers 1

Calls 4

format_vectorFunction · 0.70
appendMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected