diff options
author | mhsn <mail@mhsn.net> | 2024-12-01 12:01:00 +0000 |
---|---|---|
committer | mhsn <mail@mhsn.net> | 2024-12-01 12:01:00 +0000 |
commit | 9015922392c9881ca62871692c3a6671243c1fe3 (patch) | |
tree | 3ced4980927b65675c07cfc0d8967feba85cf3b7 /bench | |
parent | 0b1a6fc65a62a656bef6055027faf2f5e1f3235a (diff) | |
download | aoc-9015922392c9881ca62871692c3a6671243c1fe3.tar.gz aoc-9015922392c9881ca62871692c3a6671243c1fe3.zip |
Add util scripts
Diffstat (limited to 'bench')
-rwxr-xr-x | bench | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +#!/usr/bin/env zsh + +year=$1 +day=$2 +lang=$3 +input=$4 +warmups=${5:=0} + +script=$(readlink -f "$0") +script_path=$(dirname "$script") + +aoc_path=$script_path/$1/$2 +data_path="$aoc_path/data/$4.txt" + +# Check it is correct +$script_path/check $1 $2 $3 $4 > /dev/null +[[ ! $? ]] && echo "Incorrect solution" && exit 1 + + +if [[ $lang == "python" ]]; then + exec="python $aoc_path/python/main.py" +elif [[ $lang == "rust" ]]; then + # Compile first + cargo build --release --target-dir /tmp/aoc_rust --manifest-path $aoc_path/rust/Cargo.toml + exec="/tmp/aoc_rust/release/aoc_$year-$day" +else + echo "Unknown lang: $lang" + exit 1 +fi + +hyperfine --shell=none --warmup=$warmups --input=$data_path $exec |