#!/bin/zsh -e for DIR in day?? do cd "${DIR}" cargo build --release for PART in ./both*part*sh do for I in `seq 10`; do time "${PART}" >/dev/null done 2> timing.txt done ALL_TIMINGS="`cat timing.txt | sed 's/.* \([0-9.]*\) total/\1 +/'`" NO_OF_TIMINGS=`echo "${ALL_TIMINGS}" | wc -l` MEAN_TIMING=`echo $[ (${ALL_TIMINGS} 0.0005)/${NO_OF_TIMINGS} ]` cd .. echo "${DIR} ${MEAN_TIMING}" echo "${DIR} ${MEAN_TIMING}" > mean_timings.txt done