From 9049f03032599ef86b91679572a5e532bd5f428a Mon Sep 17 00:00:00 2001 From: Simon Lindholm Date: Sat, 24 Apr 2021 20:49:12 +0200 Subject: [PATCH] Use pre-compiled headers to speed up tests --- .gitignore | 1 + doc/scripts/compile-all.sh | 8 +++++--- doc/scripts/run-all.sh | 7 ++++++- doc/scripts/test-compiles.sh | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3a00b29..3badffc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /build/ *.aux *.log +*.gch a.out header.tmp .vscode diff --git a/doc/scripts/compile-all.sh b/doc/scripts/compile-all.sh index 50cee78..aaa815f 100755 --- a/doc/scripts/compile-all.sh +++ b/doc/scripts/compile-all.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash DIR=${1:-.} + +# use a precompiled header for the template to improve perf +g++ -Wall -Wextra -Wfatal-errors -Wconversion -std=c++14 -x c++-header $DIR/content/contest/template.cpp +trap "rm -f $DIR/content/contest/template.cpp.gch" EXIT + SCRIPT_DIR=$DIR/doc/scripts tests="$(find $DIR/content -name '*.h' | grep -vFf $SCRIPT_DIR/skip_headers)" echo "skipped: " @@ -7,7 +12,6 @@ find $DIR/content -name '*.h' | grep -Ff $SCRIPT_DIR/skip_headers declare -i pass=0 declare -i fail=0 failHeaders="" -ulimit -s 524288 # For 2-sat test for test in $tests; do echo "$(basename $test): " $SCRIPT_DIR/test-compiles.sh $test @@ -19,11 +23,9 @@ for test in $tests; do else pass+=1 fi - rm -f a.out echo done echo "$pass/$(($pass+$fail)) tests passed" - if (($pass == 0)); then echo "No tests found (make sure skip_headers doesn't have whitespace lines)" exit 1 diff --git a/doc/scripts/run-all.sh b/doc/scripts/run-all.sh index 6a1611f..0511e51 100755 --- a/doc/scripts/run-all.sh +++ b/doc/scripts/run-all.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash DIR=${1:-.} + +# use a precompiled header for the template to improve perf +g++ -Wall -Wfatal-errors -Wconversion -std=c++17 -O2 $DIR/stress-tests/utilities/template.h +trap "rm -f $DIR/stress-tests/utilities/template.h.gch" EXIT + tests="$(find $DIR/stress-tests -name '*.cpp')" declare -i pass=0 declare -i fail=0 @@ -8,7 +13,7 @@ ulimit -s 524288 # For 2-sat test for test in $tests; do echo "$(basename $test): " start=`date +%s.%N` - g++ -std=c++17 -O2 $test && ./a.out + g++ -Wall -Wfatal-errors -Wconversion -std=c++17 -O2 $test && ./a.out retCode=$? if (($retCode != 0)); then echo "Failed with $retCode" diff --git a/doc/scripts/test-compiles.sh b/doc/scripts/test-compiles.sh index cd6014d..40dc4b8 100755 --- a/doc/scripts/test-compiles.sh +++ b/doc/scripts/test-compiles.sh @@ -4,4 +4,4 @@ echo " #include \"../content/contest/template.cpp\" #include \"../$FILE\" " >build/temp.cpp -g++ -Wall -Wextra -Wfatal-errors -Wconversion -std=c++14 build/temp.cpp && rm a.out build/temp.cpp \ No newline at end of file +g++ -Wall -Wextra -Wfatal-errors -Wconversion -std=c++14 build/temp.cpp && rm a.out build/temp.cpp