blob: d308b197ed81d91b8167d21bc1b107204169033d (
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
|
#!/bin/sh -e
YEAR="${YEAR:-$(date +%Y)}"
DAY="${DAY:-$(TZ=EST date '+%d')}"
IMPL="${IMPL:-rust}"
PARTS="${AOC_PARTS:-1 2}"
ITERS="${ITERS:-10}"
cd "${YEAR}/${IMPL}/day${DAY}"
case "${IMPL}" in
'rust')
cargo build --release
EXECUTABLE="../target/release/day${DAY}"
;;
*)
echo "Unknown implementation: ${IMPL}" >&2
exit
;;
esac
for PART in $(echo ${PARTS})
do
export AOC_PARTS="${PART}"
OUT="time-${YEAR}-${IMPL}-${DAY}-${PART}.txt"
export TIMEFMT='%uE'
for I in $(seq "${ITERS}"); do
zsh -c time "${EXECUTABLE}" "${@}" 2>&1 >/dev/null | tail -1
done >"${OUT}"
ALL_TIMINGS="$(cat "${OUT}" | sed 's/us/ + /' )"
NO_OF_ITERS=$(echo "${ALL_TIMINGS}" | wc -l)
ARITHM="$(echo "( ${ALL_TIMINGS}" | tr -d '\n'; \
echo "0 ) / ${NO_OF_ITERS}" )"
MEAN_TIMING=$(( $(echo ${ARITHM}) ))
printf "${YEAR}-${IMPL}-${DAY}-${PART}: Mean: ${MEAN_TIMING}µs\n"
printf "${YEAR}-${IMPL}-${DAY}-${PART}: Mean: ${MEAN_TIMING}µs\n" >>"${OUT}"
done
|