File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed
Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ # Uncomment one of the following to switch between debug and opt mode
3+ OPT = -O3 -DNDEBUG -std=c++17
4+ # OPT = -g -ggdb -fsanitize=address -fno-omit-frame-pointer -Wextra -fsanitize=undefined
5+
6+ CXXFLAGS += -fno-strict-aliasing -Wall -std=c++11 -I. -I../src/ \
7+ -I../src/bloom/ -I../src/cuckoo/ -I../src/gcs \
8+ -I../src/gqf/ -I../src/morton/ -I../src/xorfilter -I../src/ribbon \
9+ -I../src/vqf \
10+ $(OPT )
11+
12+ UNAME_P := $(shell uname -p)
13+ ifeq ($(UNAME_P ) ,x86_64)
14+ CXXFLAGS += -march=native
15+ else
16+ CXXFLAGS +=
17+ endif
18+ LDFLAGS = -Wall -Wextra
19+
20+ HEADERS = $(wildcard ../src/* .h \
21+ ../src/bloom/* .h ../src/cuckoo/* .h ../src/gcs/* .h \
22+ ../src/gqf/* .h ../src/morton/* .h ../src/xorfilter/* .h ../src/ribbon/* .h \
23+ ../src/vqf/* .h \
24+ ) *.h
25+
26+ .PHONY : all
27+
28+ BINS = unit
29+
30+ all : $(BINS )
31+
32+ clean :
33+ /bin/rm -f $(BINS )
34+
35+ % .exe : % .cc ${HEADERS} Makefile
36+ $(CXX ) $(CXXFLAGS ) $< -o $@ $(LDFLAGS )
Original file line number Diff line number Diff line change 1+ #include " bloom.h"
2+ #include < random>
3+ #include < iostream>
4+
5+ bool check_bloom () {
6+ std::cout << " testing Bloom" << std::endl;
7+ bloomfilter::BloomFilter<uint64_t , 18 , false > bf (65536 );
8+ for (uint64_t i = 0 ; i < 65536 ; i++) {
9+ bf.Add (i);
10+ }
11+ std::mt19937 gen;
12+ std::discrete_distribution<> bytes_count;
13+ std::uniform_int_distribution<uint64_t > val_64bit{0x0 , 0xffffffffffffffff };
14+ uint64_t cnt = 0 ;
15+ uint64_t count = 50000000 ;
16+ for (uint64_t i = 0 ; i < count; i++)
17+ {
18+ int ans = bf.Contain (val_64bit (gen));
19+ if (ans != 1 ) { cnt++; }
20+ }
21+ double rate = double (cnt)/count;
22+ std::cout << double (cnt)/count << std::endl;
23+ return rate < 0.00018 ;
24+ }
25+
26+ int main () {
27+ return check_bloom () ? EXIT_SUCCESS : EXIT_FAILURE;
28+ }
You can’t perform that action at this time.
0 commit comments