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 | local sh=$1
|
12 | shift
|
13 | ninja $sh
|
14 | valgrind --tool=callgrind $sh "$@"
|
15 | }
|
16 |
|
17 | osh-run() {
|
18 | build-and-run _bin/cxx-dbg/osh "$@"
|
19 | }
|
20 |
|
21 | ysh-run() {
|
22 | build-and-run _bin/cxx-dbg/ysh "$@"
|
23 | }
|
24 |
|
25 | fib() {
|
26 | osh-run benchmarks/compute/fib.sh 10 44
|
27 | }
|
28 |
|
29 | pretty() {
|
30 | # takes 44 seconds to collect 1.6 MB of data
|
31 | # benchmarks/testdata/functions
|
32 |
|
33 | # Measure one of our own scripts
|
34 | # Takes 3 seconds
|
35 | time osh-run -n --ast-format text install
|
36 | }
|
37 |
|
38 | parse-cpython-configure() {
|
39 | # Goal: eliminate string slicing in this workload! It should just be
|
40 | # creating fixed size Tokens, syntax.asdl nodes, and List<T>
|
41 |
|
42 | ysh-run -n --ast-format none Python-2.7.13/configure
|
43 | }
|
44 |
|
45 | json() {
|
46 | # 50 lines
|
47 | ysh-run test/bug-2123.ysh 50
|
48 | }
|
49 |
|
50 | with-callgrind() {
|
51 | local out_file=$1 # Ignored for now, same interface as with-cachegrind
|
52 | shift
|
53 |
|
54 | valgrind --tool=callgrind \
|
55 | "$@"
|
56 | }
|
57 |
|
58 | install-kcachegrind() {
|
59 | sudo apt-get install kcachegrind
|
60 | }
|
61 |
|
62 | file=$(basename $0)
|
63 | if test $file = 'callgrind.sh'; then
|
64 | "$@"
|
65 | fi
|