| 1 | #!/usr/bin/env bash
 | 
| 2 | #
 | 
| 3 | # Usage:
 | 
| 4 | #   benchmarks/report.sh <function name>
 | 
| 5 | 
 | 
| 6 | set -o nounset
 | 
| 7 | set -o pipefail
 | 
| 8 | set -o errexit
 | 
| 9 | 
 | 
| 10 | source benchmarks/common.sh  # maybe-tree
 | 
| 11 | source build/dev-shell.sh  # R_LIBS_USER
 | 
| 12 | source test/common.sh  # log
 | 
| 13 | 
 | 
| 14 | # TODO: Move stuff from osh-parser.sh, osh-runtime.sh, etc.
 | 
| 15 | #
 | 
| 16 | # stage1 : concatenate files from different machines
 | 
| 17 | # stage2 : make CSV files with report.R
 | 
| 18 | # stage3 : make HTML files.  Call 'print-report' function.
 | 
| 19 | 
 | 
| 20 | 
 | 
| 21 | stage2() {
 | 
| 22 |   local base_dir=$1  # _tmp/{osh-parser,osh-runtime,...}
 | 
| 23 |   local action=$(basename $base_dir)
 | 
| 24 | 
 | 
| 25 |   local out=$base_dir/stage2
 | 
| 26 |   mkdir -p $out
 | 
| 27 | 
 | 
| 28 |   benchmarks/report.R $action $base_dir/stage1 $out
 | 
| 29 | 
 | 
| 30 |   maybe-tree $out
 | 
| 31 | }
 | 
| 32 | 
 | 
| 33 | stage3() {
 | 
| 34 |   local base_dir=$1  # _tmp/{osh-parser,osh-runtime,...}
 | 
| 35 |   local name=${2:-$(basename $base_dir)}
 | 
| 36 |   local script=benchmarks/$name.sh
 | 
| 37 | 
 | 
| 38 |   local out=$base_dir/index.html
 | 
| 39 |   mkdir -p $(dirname $out)
 | 
| 40 | 
 | 
| 41 |   $script print-report $base_dir/stage2 > $out
 | 
| 42 | 
 | 
| 43 |   echo "Wrote $out"
 | 
| 44 | }
 | 
| 45 | 
 | 
| 46 | osh-parser() {
 | 
| 47 |   local base_dir=_tmp/osh-parser
 | 
| 48 | 
 | 
| 49 |   benchmarks/osh-parser.sh stage1 ../benchmark-data/osh-parser
 | 
| 50 |   stage2 $base_dir
 | 
| 51 |   stage3 $base_dir
 | 
| 52 | }
 | 
| 53 | 
 | 
| 54 | osh-runtime() {
 | 
| 55 |   local base_dir=_tmp/osh-runtime
 | 
| 56 | 
 | 
| 57 |   benchmarks/osh-runtime.sh stage1 ../benchmark-data/osh-runtime
 | 
| 58 |   stage2 $base_dir
 | 
| 59 |   stage3 $base_dir
 | 
| 60 | }
 | 
| 61 | 
 | 
| 62 | # NOTE: This is just processing
 | 
| 63 | vm-baseline() {
 | 
| 64 |   local base_dir=_tmp/vm-baseline
 | 
| 65 | 
 | 
| 66 |   benchmarks/vm-baseline.sh stage1 ../benchmark-data/vm-baseline
 | 
| 67 |   stage2 $base_dir
 | 
| 68 |   stage3 $base_dir
 | 
| 69 | }
 | 
| 70 | 
 | 
| 71 | ovm-build() {
 | 
| 72 |   local base_dir=_tmp/ovm-build
 | 
| 73 | 
 | 
| 74 |   benchmarks/ovm-build.sh stage1 ../benchmark-data/ovm-build
 | 
| 75 |   stage2 $base_dir
 | 
| 76 |   stage3 $base_dir
 | 
| 77 | }
 | 
| 78 | 
 | 
| 79 | compute() {
 | 
| 80 |   local base_dir=_tmp/compute
 | 
| 81 | 
 | 
| 82 |   benchmarks/compute.sh stage1 ../benchmark-data/compute
 | 
| 83 |   stage2 $base_dir
 | 
| 84 |   stage3 $base_dir
 | 
| 85 | }
 | 
| 86 | 
 | 
| 87 | all() {
 | 
| 88 |   osh-parser
 | 
| 89 |   osh-runtime
 | 
| 90 |   vm-baseline
 | 
| 91 |   ovm-build
 | 
| 92 |   compute
 | 
| 93 | 
 | 
| 94 |   # Note:
 | 
| 95 |   # benchmarks/mycpp and benchmarks/gc run on one machine, and are done in
 | 
| 96 |   # benchmarks/auto.sh
 | 
| 97 | }
 | 
| 98 | 
 | 
| 99 | # For view
 | 
| 100 | dev-index() {
 | 
| 101 |   local out=_tmp/benchmarks.html
 | 
| 102 |   for name in osh-parser osh-runtime vm-baseline ovm-build; do
 | 
| 103 |     echo "<a href=\"$name/index.html\">$name</a> <br/>"
 | 
| 104 |   done > $out
 | 
| 105 |   log "Wrote $out"
 | 
| 106 | }
 | 
| 107 | 
 | 
| 108 | report-test() {
 | 
| 109 |   benchmarks/report_test.R
 | 
| 110 | }
 | 
| 111 | 
 | 
| 112 | "$@"
 |