From e7d1a85be59121ac2cc448fbd99ce26821cc6e59 Mon Sep 17 00:00:00 2001 From: cos Date: Thu, 12 Dec 2019 17:33:35 +0100 Subject: Add measurement of peak memory usage --- 2019/rust/mem-measure_most.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 2019/rust/mem-measure_most.sh (limited to '2019/rust/mem-measure_most.sh') diff --git a/2019/rust/mem-measure_most.sh b/2019/rust/mem-measure_most.sh new file mode 100755 index 0000000..b7dd4a2 --- /dev/null +++ b/2019/rust/mem-measure_most.sh @@ -0,0 +1,28 @@ +#!/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 -- cgit v1.2.3