diff options
author | mhsn <mail@mhsn.net> | 2025-09-12 20:20:30 +0100 |
---|---|---|
committer | mhsn <mail@mhsn.net> | 2025-09-12 20:21:37 +0100 |
commit | 9299c4ef655b88eb8b571864c939c78b27f77723 (patch) | |
tree | ce75b6b8db1b44872d5fa650ccd580645b434015 /check | |
parent | fbe8b607b31f4bf914c1157872bc7a7337aea064 (diff) | |
download | aoc-9299c4ef655b88eb8b571864c939c78b27f77723.tar.gz aoc-9299c4ef655b88eb8b571864c939c78b27f77723.zip |
merge bench into check
Diffstat (limited to 'check')
-rwxr-xr-x | check | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1,10 +1,11 @@ #!/usr/bin/env sh -usage="usage: check <year> <day> <language> <testfile>" +usage="usage: check <year> <day> <language> <testfile> [<benchmark>]" year=${1?$usage} day=${2?$usage} lang=${3?$usage} input=${4?$usage} +bench=$5 # get directory of this script script=$(readlink -f "$0") @@ -16,13 +17,15 @@ data_path="$aoc_path/data/$input.txt" case $lang in "python") - cmd="uv run --directory $aoc_path/python main.py" + solve="$aoc_path/python.py" ;; "rust") - cmd="cargo run --manifest-path $aoc_path/rust/Cargo.toml --" + cargo build --target-dir /tmp/aoc_rust --manifest-path $aoc_path/rust/Cargo.toml + solve="/tmp/aoc_rust/debug/aoc_$year-$day" ;; "rustc") - cmd="cargo run --release --manifest-path $aoc_path/rust/Cargo.toml --" + cargo build --release --target-dir /tmp/aoc_rust --manifest-path $aoc_path/rust/Cargo.toml + solve="/tmp/aoc_rust/release/aoc_$year-$day" ;; "*") echo "unknown lang: $lang" @@ -30,11 +33,14 @@ case $lang in ;; esac -result=$(cat $data_path | $cmd) +result=$(cat $data_path | $solve) diff=$(echo "$result" | diff $aoc_path/data/$4.ans -) code=$? [ $code -eq 0 ] && echo Solved with $lang! || echo "$diff" + +[ -n "$bench" ] && hyperfine --shell none --input $data_path "$solve" && exit 0 + echo "\n---stdout---" echo "$result" exit $code |