Advent-of-Code-Aggregator/2023/complete-benchmark

49 lines
912 B
Text
Raw Normal View History

2023-11-30 21:41:08 +01:00
#!/bin/sh
2023-12-01 13:24:17 +01:00
help()
{
echo $0 [day] [part]
}
if ! test -n "$1"; then
echo "'day' is not given" >&2
help
exit 1
fi
2023-11-30 21:41:08 +01:00
day="$(printf '%02d' ${1##0})"
2023-12-01 13:24:17 +01:00
if ! test -n "$2"; then
echo "'part' is not given" >&2
help
exit 1
fi
2023-11-30 21:41:08 +01:00
part="$2"
inputfile="$PWD/inputs/${day}.txt"
if ! test -f "$inputfile"; then
2023-12-01 13:24:17 +01:00
echo "no input available at '$inputfile'" >&2
2023-11-30 21:41:08 +01:00
exit 1
fi
2023-12-01 13:24:17 +01:00
echo "Running benchmarks for day $day part $part"
2023-11-30 21:41:08 +01:00
for dir in *; do
if test -d "$dir"; then
cd "$dir"
if test -x ./prepare; then
echo "---------------------------------------------------------------------------------- $dir"
if ! ./prepare "$day" "$part" >&2; then
echo 'eh ge hebt precies niet alles geïnstalleerd staan'
else
if test -x run; then
hyperfine -n "$dir" "./run '$day' '$part' '$inputfile'"
fi
fi
fi
if test -x ./clean; then
./clean "$day" "$part" "$inputfile"
fi
cd - > /dev/null 2>&1
fi
done