summaryrefslogtreecommitdiff
path: root/2019/rust/mem-measure_most.sh
diff options
context:
space:
mode:
authorcos <cos>2019-12-12 17:33:35 +0100
committercos <cos>2019-12-12 17:33:35 +0100
commite7d1a85be59121ac2cc448fbd99ce26821cc6e59 (patch)
tree0cfde11af64ed446d8bcb36ba9bbca12afc63ce5 /2019/rust/mem-measure_most.sh
parent043c1a447fe611c54cf414e743dd521a2e0088e7 (diff)
downloadadventofcode-e7d1a85be59121ac2cc448fbd99ce26821cc6e59.zip
Add measurement of peak memory usage
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