summaryrefslogtreecommitdiff
path: root/2019/rust/mem-measure_most.sh
diff options
context:
space:
mode:
Diffstat (limited to '2019/rust/mem-measure_most.sh')
-rwxr-xr-x2019/rust/mem-measure_most.sh28
1 files changed, 28 insertions, 0 deletions
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