1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Analyze how mycpp speeds up programs.
|
4 | #
|
5 | # Usage:
|
6 | # benchmarks/mycpp.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 | readonly REPO_ROOT
|
14 |
|
15 | source benchmarks/common.sh
|
16 | source build/dev-shell.sh # R_LIBS_USER
|
17 | source soil/common.sh # find-dir-html
|
18 | source test/tsv-lib.sh # tsv2html
|
19 |
|
20 | print-report() {
|
21 | local in_dir=$1
|
22 |
|
23 | benchmark-html-head 'mycpp Code Generation'
|
24 |
|
25 | cat <<EOF
|
26 | <body class="width60">
|
27 | <p id="home-link">
|
28 | <a href="/">oilshell.org</a>
|
29 | </p>
|
30 | EOF
|
31 | cmark <<EOF
|
32 |
|
33 | ## mycpp Code Generation
|
34 |
|
35 | Measure the speedup from mycpp, and the resource usage.
|
36 |
|
37 | Source code: [oil/mycpp/examples](https://github.com/oilshell/oil/tree/master/mycpp/examples)
|
38 |
|
39 | EOF
|
40 |
|
41 | cmark <<EOF
|
42 | ### User Time (milliseconds)
|
43 |
|
44 | Lower ratios are better.
|
45 |
|
46 | EOF
|
47 |
|
48 | tsv2html $in_dir/user_time.tsv
|
49 |
|
50 | cmark <<EOF
|
51 | ### Max Resident Set Size (MB)
|
52 |
|
53 | Lower ratios are better. We use MB (powers of 10), not MiB (powers of 2).
|
54 |
|
55 | EOF
|
56 |
|
57 | tsv2html $in_dir/max_rss.tsv
|
58 |
|
59 | cmark <<EOF
|
60 | ### System Time (milliseconds)
|
61 |
|
62 | Lower ratios are better.
|
63 |
|
64 | EOF
|
65 |
|
66 | tsv2html $in_dir/sys_time.tsv
|
67 |
|
68 |
|
69 | # This file is benchmarks.wwz/mycpp-examples/ or _tmp/mycpp-examples/
|
70 | # The link only exists in the latter case
|
71 | cmark << 'EOF'
|
72 | ---
|
73 | [raw benchmark files](raw/benchmark/index.html)
|
74 |
|
75 | EOF
|
76 |
|
77 |
|
78 | if false; then
|
79 | cmark <<EOF
|
80 | ### Details
|
81 |
|
82 | EOF
|
83 |
|
84 | tsv2html $in_dir/details.tsv
|
85 | fi
|
86 |
|
87 | cat <<EOF
|
88 | </body>
|
89 | </html>
|
90 | EOF
|
91 | }
|
92 |
|
93 | soil-run() {
|
94 | # Run and report mycpp/examples BENCHMARKS only.
|
95 |
|
96 | local base_dir=${1:-_tmp/mycpp-examples}
|
97 | local in_tsv=_test/benchmark-table.tsv
|
98 |
|
99 | # Force SERIAL reexecution of benchmarks
|
100 | # Notes:
|
101 | # - This is why benchmarks don't really belong in Ninja?
|
102 | # - mycpp/TEST.sh test-translator does 'mycpp-logs-equal', which also runs
|
103 | # tests
|
104 |
|
105 | local task_dir=_test/tasks/benchmark
|
106 | rm -r -f --verbose $task_dir
|
107 | ninja -j 1 $in_tsv
|
108 |
|
109 | mkdir -p $base_dir/raw
|
110 | cp -v $in_tsv $base_dir/raw
|
111 | cp -R $task_dir/ $base_dir/raw/benchmark/
|
112 |
|
113 | local dir2=$base_dir/stage2
|
114 | mkdir -p $dir2
|
115 |
|
116 | benchmarks/report.R mycpp $base_dir/raw $dir2
|
117 |
|
118 | benchmarks/report.sh stage3 $base_dir mycpp
|
119 |
|
120 | # The data is in _test/tasks; we could move it to _test/benchmarks/mycpp/ or
|
121 | # something
|
122 | find-dir-html $base_dir/raw/benchmark
|
123 | }
|
124 |
|
125 | "$@"
|