1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Take stable measurements of GC
|
4 | #
|
5 | # Usage:
|
6 | # benchmarks/gc-cachegrind.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
|
13 |
|
14 | source benchmarks/common.sh
|
15 | source build/dev-shell.sh # $R_LIBS_USER
|
16 | source test/tsv-lib.sh
|
17 |
|
18 | readonly BASE_DIR=_tmp/gc-cachegrind
|
19 |
|
20 | print-report() {
|
21 | local in_dir=$1
|
22 |
|
23 | benchmark-html-head 'Memory Management (stable measurements)'
|
24 |
|
25 | cat <<EOF
|
26 | <body class="width60">
|
27 | <p id="home-link">
|
28 | <a href="/">oilshell.org</a>
|
29 | </p>
|
30 | EOF
|
31 |
|
32 | cmark << 'EOF'
|
33 | ## Memory Management (stable measurements)
|
34 |
|
35 | Source code: [oil/benchmarks/gc-cachegrind.sh](https://github.com/oilshell/oil/tree/master/benchmarks/gc-cachegrind.sh)
|
36 | EOF
|
37 |
|
38 | cmark <<'EOF'
|
39 | #### parse.abuild
|
40 |
|
41 | EOF
|
42 |
|
43 | tsv2html $in_dir/parse.abuild.tsv
|
44 |
|
45 | cmark <<'EOF'
|
46 | #### ex.compute-fib
|
47 |
|
48 | EOF
|
49 |
|
50 | tsv2html $in_dir/ex.compute-fib.tsv
|
51 |
|
52 |
|
53 | cat <<EOF
|
54 |
|
55 | </body>
|
56 | </html>
|
57 | EOF
|
58 | }
|
59 |
|
60 | make-report() {
|
61 | mkdir -p $BASE_DIR/{stage1,stage2}
|
62 |
|
63 | # Concatenate tiny files
|
64 | benchmarks/cachegrind_to_tsv.py $BASE_DIR/raw/cachegrind-*.txt \
|
65 | > $BASE_DIR/stage1/cachegrind.tsv
|
66 |
|
67 | #pretty-tsv $BASE_DIR/stage1/cachegrind.tsv
|
68 |
|
69 | # Make TSV files
|
70 | benchmarks/report.R gc-cachegrind $BASE_DIR $BASE_DIR/stage2
|
71 |
|
72 | #pretty-tsv $BASE_DIR/stage2/counts.tsv
|
73 |
|
74 | # Make HTML
|
75 | benchmarks/report.sh stage3 $BASE_DIR
|
76 | }
|
77 |
|
78 | soil-run() {
|
79 | ### Run in soil/benchmarks2 (stable timings)
|
80 |
|
81 | benchmarks/gc.sh measure-cachegrind
|
82 |
|
83 | make-report
|
84 | }
|
85 |
|
86 | "$@"
|