Logo

index : gist

Random things

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/gist.git/html/bash/cprof.sh blob: 779cfc9a565965fc1db8a6d97640c75844d5baad [raw] [clear marker]

        
0#!/bin/bash
1
2# Creates profiling graphs as png in your current directory.
3#
4# You'll need:
5# - gprof2dot
6# - dot
7
8
9bin="$1"
10shift
11out="${bin}.callgrind"
12
13if [[ -z "$bin" || ! -x "$bin" ]]; then
14 echo "Usage: cprof <executable> [program args]"
15 exit 1
16fi
17
18valgrind --tool=callgrind \
19 --callgrind-out-file="$out" \
20 "$bin" "$@" \
21 || echo "valgrind non-zero. Continuing..."
22
23gprof2dot "$out" --format=callgrind -o out.dot || exit 1
24dot -Tpng out.dot -o graph.png || exit 1
25
26echo "done"
27
28
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit