#!/bin/bash # Creates profiling graphs as png in your current directory. # # You'll need: # - gprof2dot # - dot bin="$1" shift out="${bin}.callgrind" if [[ -z "$bin" || ! -x "$bin" ]]; then echo "Usage: cprof [program args]" exit 1 fi valgrind --tool=callgrind \ --callgrind-out-file="$out" \ "$bin" "$@" \ || echo "valgrind non-zero. Continuing..." gprof2dot "$out" --format=callgrind -o out.dot || exit 1 dot -Tpng out.dot -o graph.png || exit 1 echo "done"