blob: a38b891056d3544df7ec6b02bdfd7a5eea5f68df (
plain)
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
41
42
43
44
45
46
47
48
|
#!/usr/bin/env sh
usage="usage: bench <year> <day> <language> <testfile> [<warmups>]"
year=${1?$usage}
day=${2?$usage}
lang=${3?$usage}
input=${4?$usage}
warmups=${5:-0}
# get directory of this script
script=$(readlink -f "$0")
script_path=$(dirname "$script")
# find aoc and data paths
aoc_path=$script_path/$year/$day
data_path="$aoc_path/data/$input.txt"
# check solution is correct for this input
$script_path/check $year $day $lang $input >/dev/null
[ ! $? ] && echo "Incorrect solution" && exit 1
case $lang in
"python")
# Sync to create venv
uv sync \
--directory $aoc_path/python
# Bypass any `uv run` overhead and run .venv directly
exec="$aoc_path/python/.venv/bin/python $aoc_path/python/main.py"
;;
"rust")
# Compile to /tmp/aoc_rust and run binary
cargo build \
--release \
--target-dir /tmp/aoc_rust \
--manifest-path $aoc_path/rust/Cargo.toml
exec="/tmp/aoc_rust/release/aoc_$year-$day"
;;
*)
echo "unknown lang: $lang"
exit 1
;;
esac
hyperfine \
--shell none \
--warmup $warmups \
--input $data_path \
"$exec"
|