Skip to content

Commit

Permalink
tests/make_graph: One shot graph for all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
suizman committed Dec 4, 2018
1 parent 57be27b commit c90f351
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions tests/make_graph
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,52 @@
pattern="$1"
dir="$2"
metric="$3"
profiles='cpu'

all() {
z=$(go tool pprof -top $dir/*-0-cpu-profile.pb.gz | awk "/%.*%.*%/ { if ( NF == 6 ) { print $parse } }" | sed -e 's/(/\\\(/g' -e 's/)/\\\)/g' -e 's/\*/\\\*/g')
for i in $z
do
echo "Graph for $i"
(for prof in $(find $dir -type f -name "*$profiles*.pb.gz" | sort )
do
x=$(echo "$prof" | cut -d- -f2)
y=$(go tool pprof -top $PPROF_EXTRA_ARGS -show "$i" "$prof" 2>/dev/null | awk "/^Showing nodes accounting for / { print $parse }" | tr -d '%,' )
echo $x $y
done) | gnuplot -e 'set terminal dumb; plot "-" using 1:2 with lines; pause -1'
done
}

single() {
(for prof in $(find $dir -type f -name "*$profiles*.pb.gz" | sort )
do
x=$(echo "$prof" | cut -d- -f2)
y=$(go tool pprof -top $PPROF_EXTRA_ARGS -show "$pattern" "$prof" 2>/dev/null | awk "/^Showing nodes accounting for / { print $parse }" | tr -d '%,' )
echo $x $y
done) | gnuplot -e 'set terminal dumb; plot "-" using 1:2 with lines; pause -1'
}

case $3 in
case $1 in
all)
echo "Usage: $0 all(generate graph for each entry in the reference profile) metrics_dir)"
parse='$6'
all
;;
esac

case $metric in
cum|c)
parse='$6'
single
;;
flat|f)
parse='$5'
PPROF_EXTRA_ARGS='-unit ms'
single
;;
*)
echo "Usage: $0 pattern metrics_dir percent|time"
exit 1
;;
esac

profiles='cpu'

(for prof in $(find $dir -type f -name "*$profiles*.pb.gz" | sort )
do
x=$(echo "$prof" | cut -d- -f2)
y=$(go tool pprof -top $PPROF_EXTRA_ARGS -show "$pattern" "$prof" 2>/dev/null | awk "/^Showing nodes accounting for / { print $parse }" | tr -d '%,' )
echo $x $y
done) | gnuplot -e 'set terminal dumb; plot "-" using 1:2 with lines; pause -1'

0 comments on commit c90f351

Please sign in to comment.