forked from BTrDB/btrdb-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_matrix.py
More file actions
173 lines (156 loc) · 5.54 KB
/
create_matrix.py
File metadata and controls
173 lines (156 loc) · 5.54 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import itertools as it
import json
from typing import List
import benchmarks.utils.benchmark_stream_inserts as stream_inserts
import benchmarks.utils.benchmark_stream_reads as stream_read
import benchmarks.utils.benchmark_streamset_inserts as streamset_inserts
import benchmarks.utils.benchmark_streamset_reads as streamset_reads
import btrdb.utils.timez
def _create_param_dict(
num_points, my_func, num_repeat, width_ns, pw, num_streams
) -> dict:
tmp = {
"n_points": num_points,
"func_name": my_func.__name__,
"replica": num_repeat,
"n_streams": num_streams,
}
if "window" in my_func.__name__:
if "aligned" in my_func.__name__:
tmp["width_ns"] = None
tmp["pw"] = pw
else:
tmp["width_ns"] = width_ns
tmp["pw"] = None
else:
tmp["width_ns"] = None
tmp["pw"] = None
return tmp
def make_single_stream_benchmark_matrix(
filename: str, pts: List[int], repeats: int, widths_ns: List[int], pws: List[int]
):
"""Create the json benchmark matrix for single stream operations.
Parameters
----------
filename : str, required
The json filename to write out the benchmark parameters to.
pts : List[int], required
The list of amount of points to return for reading
repeats : int, required
How many replicas for statistics?
widths_ns : List[int], required
With window width parameters for the windows queries
pws : List[int], required
The pointwidths for the aligned_window queries
"""
prev_methods = [
stream_read.time_single_stream_raw_values,
stream_read.time_single_stream_windows_values,
stream_read.time_single_stream_aligned_windows_values,
]
arrow_methods = [
stream_read.time_single_stream_arrow_raw_values,
stream_read.time_single_stream_arrow_windows_values,
stream_read.time_single_stream_arrow_aligned_windows_values,
]
arrow_ins_methods = [stream_inserts.time_stream_arrow_insert]
stream_ins_methods = [stream_inserts.time_stream_insert]
bench_list = list()
for num_points, my_func, num_repeat, width_ns, pw in it.product(
pts,
[*arrow_methods, *prev_methods, *arrow_ins_methods, *stream_ins_methods],
range(repeats),
widths_ns,
pws,
):
tmp = _create_param_dict(
num_points, my_func, num_repeat, width_ns, pw, num_streams=1
)
bench_list.append(tmp)
with open(filename, "w") as fp:
json.dump(fp=fp, obj=bench_list)
def make_streamset_benchmark_matrix(
filename: str,
pts: List[int],
repeats: int,
n_streams: List[int],
widths_ns: List[int],
pws: List[int],
):
"""Create the json benchmark matrix for streamset operations.
Parameters
----------
filename : str, required
The json filename to write out the benchmark parameters to.
pts : List[int], required
The list of amount of points to return for reading
repeats : int, required
How many replicas for statistics?
n_streams : List[int], required
How many streams in the streamset?
widths_ns : List[int], required
With window width parameters for the windows queries
pws : List[int], required
The pointwidths for the aligned_window queries
"""
prev_methods = [
streamset_reads.time_streamset_raw_values,
streamset_reads.time_streamset_windows_values,
streamset_reads.time_streamset_aligned_windows_values,
]
arrow_methods = [
streamset_reads.time_streamset_arrow_raw_values,
streamset_reads.time_streamset_arrow_windows_values,
streamset_reads.time_streamset_arrow_aligned_windows_values,
streamset_reads.time_streamset_arrow_multistream_raw_values_non_timesnapped,
streamset_reads.time_streamset_arrow_multistream_raw_values_timesnapped,
]
arrow_ins_methods = [streamset_inserts.time_streamset_arrow_inserts]
stream_ins_methods = [streamset_inserts.time_streamset_inserts]
bench_list = list()
for num_points, my_func, num_repeat, num_streams, width_ns, pw in it.product(
pts,
[*arrow_methods, *prev_methods, *arrow_ins_methods, *stream_ins_methods],
range(repeats),
n_streams,
widths_ns,
pws,
):
# print(num_points, my_func.__name__, num_repeat)
if num_points > 1_000_000:
if "arrow" not in my_func.__name__:
continue
tmp = _create_param_dict(
num_points, my_func, num_repeat, width_ns, pw, num_streams
)
bench_list.append(tmp)
with open(filename, "w") as fp:
json.dump(fp=fp, obj=bench_list)
def main():
n_points = [10_000, 100_000, 1_000_000, 3_000_000, 5_000_000, 10_000_000]
n_repeats = 5
n_streams = [1, 5, 10, 20, 50, 100]
window_width_ns = [
btrdb.utils.timez.ns_delta(minutes=1),
btrdb.utils.timez.ns_delta(minutes=5),
]
aligned_window_pw = [36, 38] # 1.15min, 4.58min
stream_fn = "single_stream_bench_list.json"
streamset_fn = "streamset_bench_list_modified.json"
make_single_stream_benchmark_matrix(
filename=stream_fn,
pts=n_points,
repeats=n_repeats,
widths_ns=window_width_ns,
pws=aligned_window_pw,
)
make_streamset_benchmark_matrix(
filename=streamset_fn,
pts=n_points,
repeats=n_repeats,
n_streams=n_streams,
widths_ns=window_width_ns,
pws=aligned_window_pw,
)
if __name__ == "__main__":
main()