forked from docarray/docarray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmarking.py
55 lines (45 loc) · 1.47 KB
/
benchmarking.py
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
import argparse
import numpy as np
from benchmarking_utils import (
get_docs,
get_configuration_storage_backends,
plot_results,
run_benchmark,
save_benchmark_df,
)
if __name__ == "__main__":
# Parameters settable by the user
n_index_values = [1_000_000]
n_query = 1
D = 128
TENSOR_SHAPE = (512, 256)
K = 10
n_vector_queries = 1000
np.random.seed(123)
# Benchmark
storage_backends = get_configuration_storage_backends(argparse, D, True)
find_by_vector_values = {str(n_index): [] for n_index in n_index_values}
create_values = {str(n_index): [] for n_index in n_index_values}
for idx, n_index in enumerate(n_index_values):
train = [np.random.rand(D) for _ in range(n_index)]
test = [np.random.rand(D) for _ in range(n_vector_queries)]
ground_truth = []
print(f'Reading dataset')
docs = get_docs(train)
find_by_vector_time_all, create_time_all, benchmark_df = run_benchmark(
docs,
test,
ground_truth,
n_index,
n_vector_queries,
n_query,
storage_backends,
K,
)
# store find_by_vector time
find_by_vector_values[str(n_index)] = find_by_vector_time_all
create_values[str(n_index)] = create_time_all
save_benchmark_df(benchmark_df, n_index)
plot_results(
find_by_vector_values, storage_backends, create_values, plot_legend=False
)