1 | #!/usr/bin/env bash
|
2 | #
|
3 | # cachegrind gives instruction counts
|
4 | #
|
5 | # Usage:
|
6 | # benchmarks/cachegrind.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | source benchmarks/common.sh
|
13 |
|
14 | with-cachegrind() {
|
15 | ### Run a command under cachegrind, writing to $out_file
|
16 | local out_file=$1
|
17 | shift
|
18 |
|
19 | valgrind --tool=cachegrind \
|
20 | --log-file=$out_file \
|
21 | --cachegrind-out-file=/dev/null \
|
22 | -- "$@"
|
23 |
|
24 | log "Wrote $out_file"
|
25 | }
|
26 |
|
27 | file=$(basename $0)
|
28 | if test $file = 'cachegrind.sh'; then
|
29 | "$@"
|
30 | fi
|