| 1 | #!/usr/bin/env bash
 | 
| 2 | #
 | 
| 3 | # Usage:
 | 
| 4 | #   benchmarks/callgrind.sh <function name>
 | 
| 5 | 
 | 
| 6 | set -o nounset
 | 
| 7 | set -o pipefail
 | 
| 8 | set -o errexit
 | 
| 9 | 
 | 
| 10 | build-and-run() {
 | 
| 11 |   # Hm dbg build seems to give more exact info
 | 
| 12 |   local osh=_bin/cxx-dbg/osh
 | 
| 13 |   #local osh=_bin/cxx-opt/osh
 | 
| 14 | 
 | 
| 15 |   ninja $osh
 | 
| 16 | 
 | 
| 17 |   valgrind --tool=callgrind \
 | 
| 18 |     $osh "$@"
 | 
| 19 | }
 | 
| 20 | 
 | 
| 21 | fib() {
 | 
| 22 |   build-and-run benchmarks/compute/fib.sh 10 44
 | 
| 23 | }
 | 
| 24 | 
 | 
| 25 | parse-cpython-configure() {
 | 
| 26 |   # Goal: eliminate string slicing in this workload!  It should just be
 | 
| 27 |   # creating fixed size Tokens, syntax.asdl nodes, and List<T>
 | 
| 28 | 
 | 
| 29 |   build-and-run -n --ast-format none Python-2.7.13/configure
 | 
| 30 | }
 | 
| 31 | 
 | 
| 32 | with-callgrind() {
 | 
| 33 |   local out_file=$1  # Ignored for now, same interface as with-cachegrind
 | 
| 34 |   shift
 | 
| 35 | 
 | 
| 36 |   valgrind --tool=callgrind \
 | 
| 37 |     "$@"
 | 
| 38 | }
 | 
| 39 | 
 | 
| 40 | install-kcachegrind() {
 | 
| 41 |   sudo apt-get install kcachegrind
 | 
| 42 | }
 | 
| 43 | 
 | 
| 44 | file=$(basename $0)
 | 
| 45 | if test $file = 'callgrind.sh'; then
 | 
| 46 |   "$@"
 | 
| 47 | fi
 |