mirror of
https://github.com/MariaDB/server.git
synced 2025-09-11 05:52:26 +03:00
speed up tokudb handler unit tests
This commit is contained in:
@@ -2,7 +2,11 @@ SRCS = $(wildcard *.cc)
|
||||
TARGETS = $(patsubst %.cc,%,$(SRCS))
|
||||
CHECKS = $(patsubst %,%.check,$(TARGETS))
|
||||
CPPFLAGS = -I.. -D__STDC_FORMAT_MACROS
|
||||
CXXFLAGS = -g -Wall -Wextra -Wno-missing-field-initializers -Wshadow -fopenmp
|
||||
CXXFLAGS = -g -Wall -Wextra -Wno-missing-field-initializers -Wshadow
|
||||
ifdef USE_OPENMP
|
||||
CPPFLAGS += -DUSE_OPENMP
|
||||
CXXFLAGS += -fopenmp
|
||||
endif
|
||||
|
||||
FRACTALTREE_BASE_DIR = ../ft-index
|
||||
FRACTALTREE_INSTALL_DIR = $(FRACTALTREE_BASE_DIR)/install.debug
|
||||
@@ -17,21 +21,29 @@ all: $(TARGETS)
|
||||
clean:
|
||||
rm -rf $(TARGETS) *.gcov *.gcno *.gcda *.testdir *.dSYM
|
||||
|
||||
check: $(CHECKS)
|
||||
true
|
||||
|
||||
%.check: %
|
||||
LD_LIBRARY_PATH=$(FRACTALTREE_INSTALL_DIR)/lib $(VALGRIND) ./$<
|
||||
|
||||
card.check: card_test.check card_1.check card_inf.check card_inf_1.check card_random_1.check card_etime.check
|
||||
true
|
||||
|
||||
ifndef USE_OPENMP
|
||||
# unravel vlq_test_uint64 8 times
|
||||
vlq_test_uint64_%.check:
|
||||
LD_LIBRARY_PATH=$(FRACTALTREE_INSTALL_DIR)/lib $(VALGRIND) ./vlq_test_uint64 $(patsubst vlq_test_uint64_%.check,%,$@) 8
|
||||
vlq_test_uint64.check: $(foreach i,0 1 2 3 4 5 6 7,vlq_test_uint64_$(i).check)
|
||||
true
|
||||
endif
|
||||
|
||||
vlq.check: vlq_test.check vlq_test_uint32.check vlq_test_uint64.check
|
||||
true
|
||||
|
||||
max_test.check: max_test
|
||||
$(VALGRIND) ./$< 1 2
|
||||
|
||||
check: $(CHECKS)
|
||||
true
|
||||
|
||||
%: %.cc
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -o $@ $<
|
||||
|
||||
|
@@ -101,9 +101,11 @@ namespace tokudb {
|
||||
template size_t vlq_decode_ui(uint64_t *np, void *p, size_t s);
|
||||
};
|
||||
|
||||
static void test_vlq_uint64(void) {
|
||||
// test a slice of the number space where the slice is described by
|
||||
// a start number and a stride through the space.
|
||||
static void test_vlq_uint64(uint64_t start, uint64_t stride) {
|
||||
printf("%u\n", 0);
|
||||
for (uint64_t v = 0; v < (1<<7); v++) {
|
||||
for (uint64_t v = 0 + start; v < (1<<7); v += stride) {
|
||||
unsigned char b[10];
|
||||
size_t out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
|
||||
assert(out_s == 1);
|
||||
@@ -113,7 +115,7 @@ static void test_vlq_uint64(void) {
|
||||
}
|
||||
|
||||
printf("%u\n", 1<<7);
|
||||
for (uint64_t v = (1<<7); v < (1<<14); v++) {
|
||||
for (uint64_t v = (1<<7) + start; v < (1<<14); v += stride) {
|
||||
unsigned char b[10];
|
||||
size_t out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
|
||||
assert(out_s == 2);
|
||||
@@ -123,7 +125,7 @@ static void test_vlq_uint64(void) {
|
||||
}
|
||||
|
||||
printf("%u\n", 1<<14);
|
||||
for (uint64_t v = (1<<14); v < (1<<21); v++) {
|
||||
for (uint64_t v = (1<<14) + start; v < (1<<21); v += stride) {
|
||||
unsigned char b[10];
|
||||
size_t out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
|
||||
assert(out_s == 3);
|
||||
@@ -133,7 +135,7 @@ static void test_vlq_uint64(void) {
|
||||
}
|
||||
|
||||
printf("%u\n", 1<<21);
|
||||
for (uint64_t v = (1<<21); v < (1<<28); v++) {
|
||||
for (uint64_t v = (1<<21) + start; v < (1<<28); v += stride) {
|
||||
unsigned char b[10];
|
||||
size_t out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
|
||||
assert(out_s == 4);
|
||||
@@ -143,9 +145,11 @@ static void test_vlq_uint64(void) {
|
||||
}
|
||||
|
||||
printf("%u\n", 1<<28);
|
||||
#if USE_OPENMP
|
||||
#pragma omp parallel num_threads(4)
|
||||
#pragma omp for
|
||||
for (uint64_t v = (1<<28); v < (1ULL<<35); v++) {
|
||||
#endif
|
||||
for (uint64_t v = (1<<28) + start; v < (1ULL<<35); v += stride) {
|
||||
unsigned char b[10];
|
||||
size_t out_s = tokudb::vlq_encode_ui<uint64_t>(v, b, sizeof b);
|
||||
assert(out_s == 5);
|
||||
@@ -155,7 +159,12 @@ static void test_vlq_uint64(void) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_vlq_uint64();
|
||||
int main(int argc, char *argv[]) {
|
||||
uint64_t start = 0, stride = 1;
|
||||
if (argc == 3) {
|
||||
start = atoll(argv[1]);
|
||||
stride = atoll(argv[2]);
|
||||
}
|
||||
test_vlq_uint64(start, stride);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user