@@ -62,6 +62,7 @@ void resume_timing()
62
62
#include < cstdlib>
63
63
#include < iomanip>
64
64
#include < iostream>
65
+ #include < limits>
65
66
#include < string>
66
67
#include < vector>
67
68
@@ -85,14 +86,20 @@ struct test_results
85
86
double insertion_time; /* ns per element */
86
87
double successful_lookup_time; /* ns per element */
87
88
double unsuccessful_lookup_time; /* ns per element */
89
+ double mixed_lookup_time; /* ns per element */
88
90
};
89
91
90
92
template <typename Filter>
91
93
test_results test (std::size_t c)
92
94
{
93
95
using value_type=typename Filter::value_type;
94
96
95
- std::vector<value_type> data_in,data_out;
97
+ static constexpr double lookup_mix=0.1 ; /* successful pr. */
98
+ static constexpr std::uint64_t mixed_lookup_cut=
99
+ (std::uint64_t )(
100
+ lookup_mix*(double )(std::numeric_limits<std::uint64_t >::max)());
101
+
102
+ std::vector<value_type> data_in,data_out,data_mixed;
96
103
{
97
104
boost::detail::splitmix64 rng;
98
105
boost::unordered_flat_set<value_type> unique;
@@ -114,6 +121,9 @@ test_results test(std::size_t c)
114
121
}
115
122
}
116
123
}
124
+ for (std::size_t i=0 ;i<num_elements;++i){
125
+ data_mixed.push_back (rng ()<mixed_lookup_cut?data_in[i]:data_out[i]);
126
+ }
117
127
}
118
128
119
129
double fpr=0.0 ;
@@ -143,6 +153,7 @@ test_results test(std::size_t c)
143
153
144
154
double successful_lookup_time=0.0 ;
145
155
double unsuccessful_lookup_time=0.0 ;
156
+ double mixed_lookup_time=0.0 ;
146
157
{
147
158
Filter f (c*num_elements);
148
159
for (const auto & x:data_in)f.insert (x);
@@ -158,9 +169,17 @@ test_results test(std::size_t c)
158
169
return res;
159
170
});
160
171
unsuccessful_lookup_time=t/num_elements*1E9 ;
172
+ t=measure ([&]{
173
+ std::size_t res=0 ;
174
+ for (const auto & x:data_mixed)res+=f.may_contain (x);
175
+ return res;
176
+ });
177
+ mixed_lookup_time=t/num_elements*1E9 ;
161
178
}
162
179
163
- return {fpr,insertion_time,successful_lookup_time,unsuccessful_lookup_time};
180
+ return {
181
+ fpr,insertion_time,
182
+ successful_lookup_time,unsuccessful_lookup_time,mixed_lookup_time};
164
183
}
165
184
166
185
struct print_double
@@ -196,7 +215,8 @@ template<typename Filters> void row(std::size_t c)
196
215
" <td align=\" right\" >" <<print_double (res.fpr ,4 )<<" </td>\n "
197
216
" <td align=\" right\" >" <<print_double (res.insertion_time )<<" </td>\n "
198
217
" <td align=\" right\" >" <<print_double (res.successful_lookup_time )<<" </td>\n "
199
- " <td align=\" right\" >" <<print_double (res.unsuccessful_lookup_time )<<" </td>\n " ;
218
+ " <td align=\" right\" >" <<print_double (res.unsuccessful_lookup_time )<<" </td>\n "
219
+ " <td align=\" right\" >" <<print_double (res.mixed_lookup_time )<<" </td>\n " ;
200
220
});
201
221
202
222
std::cout<<
@@ -251,17 +271,19 @@ int main(int argc,char* argv[])
251
271
252
272
auto res=test<unordered_flat_set_filter<int >>(0 );
253
273
std::cout<<
254
- " <table>\n "
255
- " <tr><th colspan=\" 3 \" ><code>boost::unordered_flat_set</code></tr>\n "
274
+ " <table class= \" bordered_table \" style= \" font-size: 85%; \" >\n "
275
+ " <tr><th colspan=\" 4 \" ><code>boost::unordered_flat_set</code></tr>\n "
256
276
" <tr>\n "
257
277
" <th>insertion</th>\n "
258
278
" <th>successful<br/>lookup</th>\n "
259
279
" <th>unsuccessful<br/>lookup</th>\n "
280
+ " <th>mixed<br/>lookup</th>\n "
260
281
" </tr>\n "
261
282
" <tr>\n "
262
283
" <td align=\" right\" >" <<print_double (res.insertion_time )<<" </td>\n "
263
284
" <td align=\" right\" >" <<print_double (res.successful_lookup_time )<<" </td>\n "
264
285
" <td align=\" right\" >" <<print_double (res.unsuccessful_lookup_time )<<" </td>\n "
286
+ " <td align=\" right\" >" <<print_double (res.mixed_lookup_time )<<" </td>\n "
265
287
" </tr>\n "
266
288
" </table>\n " ;
267
289
@@ -272,15 +294,16 @@ int main(int argc,char* argv[])
272
294
" <th>FPR<br/>[%]</th>\n "
273
295
" <th>ins.</th>\n "
274
296
" <th>succ.<br/>lkp.</th>\n "
275
- " <th>uns.<br/>lkp.</th>\n " ;
297
+ " <th>uns.<br/>lkp.</th>\n "
298
+ " <th>mixed<br/>lkp.</th>\n " ;
276
299
277
300
std::cout<<
278
- " <table>\n "
301
+ " <table class= \" bordered_table \" style= \" font-size: 85%; \" >\n "
279
302
" <tr>\n "
280
303
" <th></th>\n "
281
- " <th colspan=\" 5 \" ><code>filter<int,K></code></th>\n "
282
- " <th colspan=\" 5 \" ><code>filter<int,1,block<uint64_t,K>></code></th>\n "
283
- " <th colspan=\" 5 \" ><code>filter<int,1,block<uint64_t,K>,1></code></th>\n "
304
+ " <th colspan=\" 6 \" ><code>filter<int,K></code></th>\n "
305
+ " <th colspan=\" 6 \" ><code>filter<int,1,block<uint64_t,K>></code></th>\n "
306
+ " <th colspan=\" 6 \" ><code>filter<int,1,block<uint64_t,K>,1></code></th>\n "
284
307
" </tr>\n "
285
308
" <tr>\n "
286
309
" <th>c</th>\n " <<
@@ -297,9 +320,9 @@ int main(int argc,char* argv[])
297
320
std::cout<<
298
321
" <tr>\n "
299
322
" <th></th>\n "
300
- " <th colspan=\" 5 \" ><code>filter<int,1,multiblock<uint64_t,K>></code></th>\n "
301
- " <th colspan=\" 5 \" ><code>filter<int,1,multiblock<uint64_t,K>,1></code></th>\n "
302
- " <th colspan=\" 5 \" ><code>filter<int,1,fast_multiblock32<K>></code></th>\n "
323
+ " <th colspan=\" 6 \" ><code>filter<int,1,multiblock<uint64_t,K>></code></th>\n "
324
+ " <th colspan=\" 6 \" ><code>filter<int,1,multiblock<uint64_t,K>,1></code></th>\n "
325
+ " <th colspan=\" 6 \" ><code>filter<int,1,fast_multiblock32<K>></code></th>\n "
303
326
" </tr>\n "
304
327
" <tr>\n "
305
328
" <th>c</th>\n " <<
@@ -316,9 +339,9 @@ int main(int argc,char* argv[])
316
339
std::cout<<
317
340
" <tr>\n "
318
341
" <th></th>\n "
319
- " <th colspan=\" 5 \" ><code>filter<int,1,fast_multiblock32<K>,1></code></th>\n "
320
- " <th colspan=\" 5 \" ><code>filter<int,1,fast_multiblock64<K>></code></th>\n "
321
- " <th colspan=\" 5 \" ><code>filter<int,1,fast_multiblock64<K>,1></code></th>\n "
342
+ " <th colspan=\" 6 \" ><code>filter<int,1,fast_multiblock32<K>,1></code></th>\n "
343
+ " <th colspan=\" 6 \" ><code>filter<int,1,fast_multiblock64<K>></code></th>\n "
344
+ " <th colspan=\" 6 \" ><code>filter<int,1,fast_multiblock64<K>,1></code></th>\n "
322
345
" </tr>\n "
323
346
" <tr>\n "
324
347
" <th>c</th>\n " <<
@@ -335,9 +358,9 @@ int main(int argc,char* argv[])
335
358
std::cout<<
336
359
" <tr>\n "
337
360
" <th></th>\n "
338
- " <th colspan=\" 5 \" ><code>filter<int,1,block<uint64_t[8],K>></code></th>\n "
339
- " <th colspan=\" 5 \" ><code>filter<int,1,block<uint64_t[8],K>,1></code></th>\n "
340
- " <th colspan=\" 5 \" ><code>filter<int,1,multiblock<uint64_t[8],K>></code></th>\n "
361
+ " <th colspan=\" 6 \" ><code>filter<int,1,block<uint64_t[8],K>></code></th>\n "
362
+ " <th colspan=\" 6 \" ><code>filter<int,1,block<uint64_t[8],K>,1></code></th>\n "
363
+ " <th colspan=\" 6 \" ><code>filter<int,1,multiblock<uint64_t[8],K>></code></th>\n "
341
364
" </tr>\n "
342
365
" <tr>\n "
343
366
" <th>c</th>\n " <<
0 commit comments