Skip to content

Instantly share code, notes, and snippets.

View jamesdbowman's full-sized avatar

James Bowman jamesdbowman

  • Google
  • Seattle
View GitHub Profile
@jamesdbowman
jamesdbowman / runValgrind.sh
Created March 20, 2013 06:01
Bash script to run valgrind a number of times and collect the peak memory usages.
#!/bin/bash
echo "Size, Max Heap"
for i in {1..10}
do
SIZE=$(echo "2^"$i | bc)
RES=$(valgrind --tool=massif --time-unit=B ./a.out 0 $SIZE &> /dev/null)
MEM=$(grep -B 2 "heap_tree=peak" massif.out.* | awk -F '\n' 'ln ~ /^$/ { ln = "matched"; print $1 } $1 ~ /^--$/ { ln = "" }')
MEMARR=(${MEM//=/ })
echo $SIZE", "${MEMARR[1]}
rm massif.out.*