#!/bin/zsh -e for DIR in day* do cd "${DIR}" cargo build --release if [ -e part_one.sh ]; then PARTS="part_one.sh part_two.sh" else PARTS="both_parts.sh" fi # https://stackoverflow.com/q/774556/peak-memory-usage-of-a--process for PART in `echo ${PARTS}` do OUT="${PART%*.sh}" OUT="${OUT#*_}.txt" VG="valgrind --tool=massif --pages-as-heap=yes \ --massif-out-file=massif.out" \ ./${PART}; grep mem_heap_B massif.out | \ sed -e 's/mem_heap_B=\(.*\)/\1/' | sort -g | tail -n 1 \ > "memmax-${OUT}" MEM=`cat "memmax-${OUT}"` echo ${DIR} MEM: ${MEM} $[ MEM / 1024. ]k $[ MEM /1024./1024 ]M done cd .. done