Extend test suite. Build with -O3 by default. (#42)
* Change benchmarks and add -O3 to build * Extended test suite. Makefile now buidls with -O3 by default. Added Makefile flag (mode=debug) to build with -g instead.
This commit is contained in:
parent
128cd74670
commit
5e6cd2d84f
|
@ -29,5 +29,11 @@ compiler:
|
|||
|
||||
script:
|
||||
- make cleanall
|
||||
- make
|
||||
- make -j4
|
||||
|
||||
- make test
|
||||
- make test_format
|
||||
- make test_example
|
||||
|
||||
# Test if benchmark can be built.
|
||||
# - make build_benchmark
|
||||
|
|
68
Makefile
68
Makefile
|
@ -1,9 +1,9 @@
|
|||
# directories
|
||||
# Directories.
|
||||
BIN = bin
|
||||
SRC = src
|
||||
SRCPARSER = src/parser
|
||||
|
||||
# files
|
||||
# Files.
|
||||
PARSERCPP = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
|
||||
LIBCPP = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(PARSERCPP)
|
||||
LIBOBJ = $(LIBCPP:%.cpp=%.o)
|
||||
|
@ -11,44 +11,54 @@ TESTCPP = $(shell find test/ -name '*.cpp')
|
|||
|
||||
ALLLIB = $(shell find $(SRC) -name '*.cpp' -not -path "$(SRCPARSER)/*") $(shell find $(SRC) -name '*.h' -not -path "$(SRCPARSER)/*")
|
||||
ALLTEST = $(shell find test/ -name '*.cpp') $(shell find test/ -name '*.h')
|
||||
EXAMPLESRC = $(shell find example/ -name '*.cpp') $(shell find example/ -name '*.h')
|
||||
|
||||
# compile & link flages
|
||||
CFLAGS = -std=c++11 -Wall -fPIC -g
|
||||
# Compiler & linker flags.
|
||||
CFLAGS = -std=c++11 -Wall -fPIC
|
||||
LIBFLAGS = -shared
|
||||
TARGET = libsqlparser.so
|
||||
INSTALL = /usr/local
|
||||
|
||||
CTESTFLAGS = -Wall -Isrc/ -Itest/ -L./ -std=c++11 -lstdc++ -g
|
||||
CTESTFLAGS = -Wall -Isrc/ -Itest/ -L./ -std=c++11 -lstdc++ -O3
|
||||
|
||||
# Set compile mode to -g or -O3.
|
||||
mode ?= release
|
||||
ifeq ($(mode), debug)
|
||||
CFLAGS += -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
GMAKE = make mode=$(mode)
|
||||
|
||||
all: library
|
||||
|
||||
library: $(TARGET)
|
||||
|
||||
$(TARGET): $(LIBOBJ)
|
||||
echo $(mode)
|
||||
$(CXX) $(LIBFLAGS) -o $(TARGET) $(LIBOBJ)
|
||||
|
||||
$(SRCPARSER)/flex_lexer.o: $(SRCPARSER)/flex_lexer.cpp
|
||||
$(SRCPARSER)/flex_lexer.o: $(SRCPARSER)/flex_lexer.cpp $(SRCPARSER)/bison_parser.cpp
|
||||
$(CXX) $(CFLAGS) -c -o $@ $< -Wno-sign-compare -Wno-unneeded-internal-declaration -Wno-deprecated-register
|
||||
|
||||
%.o: %.cpp $(PARSERCPP)
|
||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(SRCPARSER)/bison_parser.cpp: $(SRCPARSER)/bison_parser.y
|
||||
make -C $(SRCPARSER)/ bison_parser.cpp
|
||||
$(GMAKE) -C $(SRCPARSER)/ bison_parser.cpp
|
||||
|
||||
$(SRCPARSER)/flex_lexer.cpp: $(SRCPARSER)/flex_lexer.l
|
||||
make -C $(SRCPARSER)/ flex_lexer.cpp
|
||||
|
||||
parser:
|
||||
make -C $(SRCPARSER) all
|
||||
$(GMAKE) -C $(SRCPARSER)/ flex_lexer.cpp
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
||||
rm -rf $(BIN)
|
||||
find $(SRC) -type f -name '*.o' -delete
|
||||
$(GMAKE) -C benchmark/ clean
|
||||
|
||||
cleanparser:
|
||||
make -C $(SRCPARSER)/ clean
|
||||
$(GMAKE) -C $(SRCPARSER)/ clean
|
||||
|
||||
cleanall: clean cleanparser
|
||||
|
||||
|
@ -58,12 +68,15 @@ install:
|
|||
cp -r src $(INSTALL)/include/hsql
|
||||
find $(INSTALL)/include/hsql -not -name '*.h' -type f | xargs rm
|
||||
|
||||
format:
|
||||
astyle --options=astyle.options $(ALLLIB)
|
||||
astyle --options=astyle.options $(ALLTEST)
|
||||
#################
|
||||
### Benchmark ###
|
||||
#################
|
||||
|
||||
run_benchmark:
|
||||
make -C benchmark/ clean run
|
||||
benchmark: library
|
||||
$(GMAKE) -C benchmark/ clean run
|
||||
|
||||
build_benchmark: library
|
||||
$(GMAKE) -C benchmark/ parser_benchmark
|
||||
|
||||
############
|
||||
### Test ###
|
||||
|
@ -72,11 +85,26 @@ run_benchmark:
|
|||
test: $(BIN)/sql_tests
|
||||
bash test/test.sh
|
||||
|
||||
# test whete
|
||||
test_install:
|
||||
make -C example/
|
||||
test_example:
|
||||
$(GMAKE) -C example/
|
||||
LD_LIBRARY_PATH=./ \
|
||||
./example/example "SELECT * FROM students WHERE name = 'Max Mustermann';"
|
||||
|
||||
test_format:
|
||||
@! astyle --options=astyle.options $(ALLLIB) | grep -q "Formatted"
|
||||
@! astyle --options=astyle.options $(ALLTEST) | grep -q "Formatted"
|
||||
|
||||
$(BIN)/sql_tests: library
|
||||
@mkdir -p $(BIN)/
|
||||
$(CXX) $(CTESTFLAGS) $(TESTCPP) -o $(BIN)/sql_tests -lsqlparser
|
||||
|
||||
|
||||
############
|
||||
### Misc ###
|
||||
############
|
||||
|
||||
format:
|
||||
astyle --options=astyle.options $(ALLLIB)
|
||||
astyle --options=astyle.options $(ALLTEST)
|
||||
astyle --options=astyle.options $(EXAMPLESRC)
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
SRC = ./
|
||||
CPP = $(shell find $(SRC) -name '*.cpp')
|
||||
|
||||
CFLAGS = -std=c++11 -lstdc++ -Wall -I../src/ -L../
|
||||
CFLAGS = -std=c++11 -lstdc++ -Wall -I../src/ -L../ -O3
|
||||
|
||||
all: parser_benchmark
|
||||
|
||||
run: parser_benchmark
|
||||
@export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../ && ./parser_benchmark
|
||||
@export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../ &&\
|
||||
./parser_benchmark
|
||||
|
||||
parser_benchmark: $(CPP)
|
||||
$(CXX) $(CFLAGS) $(CPP) -o parser_benchmark -lbenchmark -lpthread -lsqlparser
|
||||
|
|
|
@ -10,12 +10,39 @@
|
|||
#include "benchmark_utils.h"
|
||||
|
||||
|
||||
PARSE_QUERY_BENCHMARK(BM_SimpleSelect,
|
||||
PARSE_QUERY_BENCHMARK(BM_Q1SimpleSelect,
|
||||
"SELECT * FROM test;");
|
||||
|
||||
PARSE_QUERY_BENCHMARK(BM_SimpleSubSelect,
|
||||
"SELECT age, street AS address FROM (SELECT * FROM data);");
|
||||
PARSE_QUERY_BENCHMARK(BM_Q2SimpleSubSelect,
|
||||
"SELECT a, b AS address FROM (SELECT * FROM test WHERE c < 100 AND b > 3) t1 WHERE a < 10 AND b < 100;");
|
||||
|
||||
PARSE_QUERY_BENCHMARK(BM_Q3SingleJoin,
|
||||
"SELECT \"left\".a, \"left\".b, \"right\".a, \"right\".b FROM table_a AS \"left\" JOIN table_b AS \"right\" ON \"left\".a = \"right\".a;");
|
||||
|
||||
PARSE_QUERY_BENCHMARK(BM_Q4TPCHQuery,
|
||||
"SELECT"
|
||||
" l_orderkey,"
|
||||
" SUM(l_extendedprice * (1 - l_discount)) AS revenue,"
|
||||
" o_orderdate,"
|
||||
" o_shippriority"
|
||||
" FROM"
|
||||
" customer,"
|
||||
" orders,"
|
||||
" lineitem"
|
||||
" WHERE"
|
||||
" c_mktsegment = '%s'"
|
||||
" and c_custkey = o_custkey"
|
||||
" and l_orderkey = o_orderkey"
|
||||
" and o_orderdate < '%s'"
|
||||
" and l_shipdate > '%s'"
|
||||
" GROUP BY"
|
||||
" l_orderkey,"
|
||||
" o_orderdate,"
|
||||
" o_shippriority"
|
||||
" ORDER BY"
|
||||
" revenue DESC,"
|
||||
" o_orderdate;"
|
||||
);
|
||||
PARSE_QUERY_BENCHMARK(BM_TwoSelects,
|
||||
"SELECT * FROM test; SELECT age, street AS address FROM data;");
|
||||
|
||||
|
|
Loading…
Reference in New Issue