-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·40 lines (34 loc) · 1.12 KB
/
run.sh
File metadata and controls
executable file
·40 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob globstar
# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export SCRIPT_DIR
echo 'building ReleaseFast...'
zig build -Doptimize=ReleaseFast
set +u
if [[ x"${GITHUB_STEP_SUMMARY}" == "x" ]]; then
output=$(mktemp)
else
output=$GITHUB_STEP_SUMMARY
fi
set -u
run() {
echo "\`\`\`" | tee -a "$4"
ts=$(date +%s%N)
"$SCRIPT_DIR/zig-out/bin/adventofcode2023" $1 $2 $3 2>&1 | tee -a "$4"
echo "\`\`\`" | tee -a "$4"
echo "Done in *$((($(date +%s%N) - $ts)/1000000))ms*" 2>&1 | tee -a "$4"
}
echo "**Starting to run the application in the release mode**" | tee -a "$output"
tsTotal=$(date +%s%N)
for i in $(seq 1 25);
do
if [ -e "data/input-${i}.txt" ]
then
run $i 1 data/input-${i}.txt "$output"
run $i 2 data/input-${i}.txt "$output"
fi
done
echo "Total time running: *$((($(date +%s%N) - $tsTotal)/1000000))ms*" | tee -a "$output"
echo "Additionally, output is available in $output"