benchmarks/markdown: generate an html file
[nit.git] / benchmarks / markdown / bench_markdown.sh
1 #!/bin/bash
2 # This file is part of NIT ( http://www.nitlanguage.org ).
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # Shell script to bench nitmd over different kind of document.
17
18 source ../bench_common.sh
19 source ../bench_plot.sh
20
21 ## CONFIGURATION OPTIONS ##
22
23 # Default number of times a command must be run with bench_command
24 # Can be overrided with 'the option -n'
25 count=2
26
27 # Default number of times the input file is transformed during a single run
28 s=200
29
30 ## HANDLE OPTIONS ##
31
32 function usage()
33 {
34 echo "run_bench: [options]* benchname"
35 echo " -v: verbose mode"
36 echo " -n count: number of execution for each bar (default: $count)"
37 echo " -s size: number of transformations for each run (default: $s)"
38 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
39 echo " -h: this help"
40 }
41
42 stop=false
43 while [ "$stop" = false ]; do
44 case "$1" in
45 -v) verbose=true; shift;;
46 -h) usage; exit;;
47 -n) count="$2"; shift; shift;;
48 -s) s="$2"; shift; shift;;
49 --dry) dry_run=true; shift;;
50 *) stop=true
51 esac
52 done
53
54 ## GEN BENCHES
55 cd benches; make; cd ..
56
57 ## COMPILE ENGINES
58 cd engines; make; cd ..
59
60 NOTSKIPED="$*"
61
62 if test -z "$NOTSKIPED"; then
63 usage
64 echo "List of available benches:"
65 echo "* all: run all the benches"
66 fi
67
68 ## EFFECTIVE BENCHS ##
69 outdir="./out"
70 engdir="./engines"
71 bncdir="./benches/out"
72 mkdir -p $outdir
73 html="index.html"
74 echo >"$html" "<html><head></head><body>"
75
76 function bench_nitmd()
77 {
78 name="$FUNCNAME"
79 skip_test "$name" && return
80 prepare_res $outdir/nitmd.dat "nitmd" "nitmd"
81 for file in $bncdir/*.md; do
82 bench=`basename $file .md`
83 bench_command "$bench" "" "$engdir/nitmd/nitmd" "$file" "$s"
84 done
85 }
86 bench_nitmd
87
88 function bench_nitmd-o()
89 {
90 name="$FUNCNAME"
91 skip_test "$name" && return
92 prepare_res $outdir/nitmd-o.dat "nitmd-o" "nitmd-o"
93 for file in $bncdir/*.md; do
94 bench=`basename $file .md`
95 bench_command "$bench" "" "$engdir/nitmd/nitmd-o" "$file" "$s"
96 done
97 }
98 bench_nitmd-o
99
100 function bench_txtmark()
101 {
102 name="$FUNCNAME"
103 skip_test "$name" && return
104 prepare_res $outdir/txtmark.dat "txtmark" "txtmark"
105 for file in $bncdir/*.md; do
106 bench=`basename $file .md`
107 bench_command "$bench" "" "java" "-cp" "$engdir/txtmark/.:$engdir/txtmark/txtmark-0.11.jar" "Txtmark" "$file" "$s"
108 done
109 }
110 bench_txtmark
111
112 function bench_markdown4j()
113 {
114 name="$FUNCNAME"
115 skip_test "$name" && return
116 prepare_res $outdir/markdown4j.dat "markdown4j" "markdown4j"
117 for file in $bncdir/*.md; do
118 name=`basename $file .md`
119 bench_command "$bench" "" "java" "-cp" "$engdir/markdown4j/.:$engdir/markdown4j/markdown4j-2.2.jar" "Markdown4j" "$file" "$s"
120 done
121 }
122 bench_markdown4j
123
124 function bench_pandoc()
125 {
126 name="$FUNCNAME"
127 skip_test "$name" && return
128 prepare_res $outdir/pandoc.dat "pandoc" "pandoc"
129 for file in $bncdir/*.md; do
130 name=`basename $file .md`
131 bench_command "$bench" "" "$engdir/pandoc/pandoc" "$file" "$s"
132 done
133 }
134 bench_pandoc
135
136 if test "$#" -gt 0; then
137 plot $outdir/bench_markdown.gnu
138 fi
139
140 echo >>"$html" "</body></html>"
141
142 if test -n "$died"; then
143 echo "Some commands failed"
144 exit 1
145 fi
146 exit 0