all repos — shwarp-tools @ a791a2217ece065aea5652e46ee9892c69832dbb

Tools and scripts

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
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
#!/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))

echo -e "changes\tbld t\tbrk t\tbreaks"
echo "==============================================="

i=$((0))
breaks=$((0))
break_seconds=$((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)

            ((breaks++))
        fi

        echo -ne "\r${i}\t${build_seconds}\t${break_seconds}\t${breaks}"
    fi

    ((i++))
done

echo
echo "Active build time: $(date -ud "@$build_seconds" +"$(( $build_seconds/3600/24 )) days %H hours %M minutes %S seconds") (estimated)"

head_timestamp=$(git -C "$GIT_DIR" log --format=format:%at | head -1)
tail_timestamp=$(git -C "$GIT_DIR" log --format=format:%at | tail -1)
total_build_seconds=$(echo "${head_timestamp}-${tail_timestamp}" | bc)
echo "Total build time:  $(date -ud "@$total_build_seconds" +"$(( $total_build_seconds/3600/24 )) days %H hours %M minutes %S seconds")"