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

117 lines, 40 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 test/tsv-lib.sh # tsv2html
18
19print-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>
29EOF
30 cmark <<EOF
31
32## mycpp Code Generation
33
34Measure the speedup from mycpp, and the resource usage.
35
36Source code: [oil/mycpp/examples](https://github.com/oilshell/oil/tree/master/mycpp/examples)
37
38EOF
39
40 cmark <<EOF
41### User Time (milliseconds)
42
43Lower ratios are better.
44
45EOF
46
47 tsv2html $in_dir/user_time.tsv
48
49 cmark <<EOF
50 ### Max Resident Set Size (MB)
51
52Lower ratios are better. We use MB (powers of 10), not MiB (powers of 2).
53
54EOF
55
56 tsv2html $in_dir/max_rss.tsv
57
58 cmark <<EOF
59### System Time (milliseconds)
60
61Lower ratios are better.
62
63EOF
64
65 tsv2html $in_dir/sys_time.tsv
66
67 cmark << 'EOF'
68---
69[raw benchmark files](raw/benchmark/-wwz-index)
70
71EOF
72
73
74if false; then
75 cmark <<EOF
76### Details
77
78EOF
79
80 tsv2html $in_dir/details.tsv
81fi
82
83 cat <<EOF
84 </body>
85</html>
86EOF
87}
88
89soil-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"$@"