Skip to content

Commit

Permalink
Use pre-compiled headers to speed up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlindholm committed Apr 24, 2021
1 parent ac77406 commit 9049f03
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/build/
*.aux
*.log
*.gch
a.out
header.tmp
.vscode
8 changes: 5 additions & 3 deletions doc/scripts/compile-all.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/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: "
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
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion doc/scripts/run-all.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion doc/scripts/test-compiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
g++ -Wall -Wextra -Wfatal-errors -Wconversion -std=c++14 build/temp.cpp && rm a.out build/temp.cpp

0 comments on commit 9049f03

Please sign in to comment.