build-time (view raw, download)
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 |
#!/usr/bin/env bash
if [[ $# -lt 1 ]]
then
echo "Usage: ./build-time <WAD_PATH>"
echo -e "\texample: ./build-time ~/doom/WIP/my-wad.wad"
exit 1
fi
MAP_FILENAME=$(basename "$1")
GIT_DIR=$(echo ${1::-"$((${#MAP_FILENAME} + 1))"})
max_break_minutes=30
max_break_seconds=$((max_break_minutes*60))
i=$((0))
build_seconds=$((0))
build_intervals=()
for timestamp in $(git -C "$GIT_DIR" log --reverse --format=format:%at)
do
# Prime the pump
if [[ $i -eq 0 ]]
then
build_intervals+=($timestamp)
else
prev_timestamp="${build_intervals[((i-1))]}"
seconds=$(echo "(${timestamp}-${prev_timestamp})" | bc)
build_intervals+=($timestamp)
if [[ $seconds -lt $max_break_seconds ]]
then
((build_seconds+=$seconds))
else
break_seconds=$(echo "(${timestamp}-${prev_timestamp})" | bc)
fi
fi
((i++))
done
echo "Build time: ${build_seconds}s"
|