|
|
- #include "gp/algorithms/repeat.hpp"
- #include "gp/containers/probabilistic/bloomfilter.hpp"
- #include "test_scaffold.h"
-
- #include <random>
- #include <string>
-
-
- typedef std::mt19937_64 cheap_rand;
- typedef std::mt19937_64 cheap_rand_bis;
-
- struct bfilter_test : public test_scaffold {
- uint32_t seed;
-
- bfilter_test() {
- seed = std::random_device{}();
- name = __FILE__ ":1_seed";
- name += std::to_string(seed);
- }
-
- virtual int run() {
-
- cheap_rand setter(seed);
- cheap_rand getter(seed);
-
- gp::bloomfilter test_filter;
-
- for(int a = 0 ; a < 100; a++)
- {
- test_filter.set_hash(setter());
- }
-
- bool result = true;
- for(int a = 0 ; a < 100; a++)
- {
- result *= test_filter.test_hash(getter());
- }
-
- return !result;
- }
- };
-
- append_test dummy_r21fg6r43(new bfilter_test{});
-
- struct bfilter2_test : public test_scaffold {
- uint32_t seedA;
- uint32_t seedB;
-
- bfilter2_test() {
- seedA = std::random_device{}();
- seedB = std::random_device{}();
- name = __FILE__ ":2_seedA";
- name += std::to_string(seedA);
- name += "&seedB";
- name += std::to_string(seedB);
- }
-
- bfilter2_test(uint32_t a, uint32_t b) {
- seedA = a;
- seedB = b;
- name = __FILE__ ":2_seedA";
- name += std::to_string(seedA);
- name += "&seedB";
- name += std::to_string(seedB);
- }
-
- virtual int run() {
-
- cheap_rand setter(seedA);
- cheap_rand_bis getter(seedB);
- int interference = 0;
- auto cnt = 300;
-
- gp::repeat(cnt, [&](){
- gp::bloomfilter test_filter;
-
- for(int a = 0 ; a < 10000; a++)
- {
- test_filter.set_hash(setter());
- }
-
- for(int a = 0 ; a < 10000; a++)
- {
- interference += test_filter.test_hash(getter()) == true;
- }
- });
-
- float avg = interference / (float)cnt;
-
- return avg >= 210;
- }
- };
-
- append_test dummy_r2gflu3(new bfilter2_test{});
- append_test dummy_rsdgueiu3(new bfilter2_test{3780040561, 79423740});
-
- struct bfilter3_test : public test_scaffold {
- uint32_t seed;
-
- bfilter3_test() {
- seed = std::random_device{}();
- name = __FILE__ ":3_seed";
- name += std::to_string(seed);
- }
-
- virtual int run() {
-
- cheap_rand setter(seed);
- cheap_rand getter(seed);
-
- gp::bloomfilter<uint32_t, 19, true> test_filter;
-
- for(int a = 0 ; a < 1000; a++)
- {
- test_filter.set_hash(setter());
- }
-
- bool result = true;
- for(int a = 0 ; a < 1000; a++)
- {
- result *= test_filter.test_hash(getter());
- }
-
- return !result;
- }
- };
-
- append_test dummy_56489flu3(new bfilter3_test{});
|