OILS / benchmarks / mycpp.sh View on Github | oilshell.org

125 lines, 42 significant
1#!/usr/bin/env bash
2#
3# Analyze how mycpp speeds up programs.
4#
5# Usage:
6# benchmarks/mycpp.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12REPO_ROOT=$(cd $(dirname $0)/.. && pwd)
13readonly REPO_ROOT
14
15source benchmarks/common.sh
16source build/dev-shell.sh # R_LIBS_USER
17source soil/common.sh # find-dir-html
18source test/tsv-lib.sh # tsv2html
19
20print-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>
30EOF
31 cmark <<EOF
32
33## mycpp Code Generation
34
35Measure the speedup from mycpp, and the resource usage.
36
37Source code: [oil/mycpp/examples](https://github.com/oilshell/oil/tree/master/mycpp/examples)
38
39EOF
40
41 cmark <<EOF
42### User Time (milliseconds)
43
44Lower ratios are better.
45
46EOF
47
48 tsv2html $in_dir/user_time.tsv
49
50 cmark <<EOF
51 ### Max Resident Set Size (MB)
52
53Lower ratios are better. We use MB (powers of 10), not MiB (powers of 2).
54
55EOF
56
57 tsv2html $in_dir/max_rss.tsv
58
59 cmark <<EOF
60### System Time (milliseconds)
61
62Lower ratios are better.
63
64EOF
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
75EOF
76
77
78if false; then
79 cmark <<EOF
80### Details
81
82EOF
83
84 tsv2html $in_dir/details.tsv
85fi
86
87 cat <<EOF
88 </body>
89</html>
90EOF
91}
92
93soil-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"$@"