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