Skip to content

Commit 2eda5b7

Browse files
Add test script for multiprocessing with progress bar
1 parent 71c1f3b commit 2eda5b7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test_multiprocessing.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from engine.base_client.search import BaseSearcher
2+
from dataset_reader.base_reader import Query
3+
import time
4+
5+
class TestSearcher(BaseSearcher):
6+
@classmethod
7+
def init_client(cls, host, distance, connection_params, search_params):
8+
pass
9+
10+
@classmethod
11+
def search_one(cls, vector, meta_conditions, top):
12+
return []
13+
14+
@classmethod
15+
def _search_one(cls, query, top=None):
16+
# Add a small delay to simulate real work
17+
time.sleep(0.001)
18+
return 1.0, 0.1
19+
20+
def setup_search(self):
21+
pass
22+
23+
# Create test queries
24+
queries = [Query(vector=[0.1]*10, meta_conditions=None, expected_result=None) for _ in range(1000)]
25+
26+
# Create a searcher with parallel=10
27+
searcher = TestSearcher('localhost', {}, {'parallel': 10})
28+
29+
# Run the search_all method
30+
start = time.perf_counter()
31+
results = searcher.search_all('cosine', queries)
32+
total_time = time.perf_counter() - start
33+
34+
print(f'Number of queries: {len(results["latencies"])}')
35+
print(f'Total time: {total_time:.6f} seconds')
36+
print(f'Throughput: {results["rps"]:.2f} queries/sec')

0 commit comments

Comments
 (0)