Skip to content

Commit

Permalink
Added callgrind.sh to automate valgrind analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Dec 7, 2024
1 parent 6f2e587 commit 9b97723
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts/callgrind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
#
# This script is intended to run Prolog goals under valgrind for
# performance analysis. This is to be combined with valgrind.pl from
# https://github.com/JanWielemaker/my-prolog-lib. For example:
#
# ```
# ../scripts/callgrind.sh src/swipl [option ...] [arg ...]
# ?- cg(Goal).
# ?- halt.
# ```

tool=--tool=callgrind
opts="--dump-instr=yes --collect-jumps=yes"

done=false
while [ $done = false ]; do
case "$1" in
--tool=cachegrind)
tool="$1"
opts=" --cache-sim=yes"
shift
;;
*)
done=true
;;
esac
done

echo "Running valgrind $tool $opts --instr-atstart=no $*"
valgrind $tool $opts --instr-atstart=no $*
kcachegrind $(ls -tr callgrind.out.* | tail -1)

0 comments on commit 9b97723

Please sign in to comment.