2 # This file is part of NIT ( http://www.nitlanguage.org ).
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # This shell script helps running benchmarks
18 # TODO: cleanup and libify the helper-parts
20 source ..
/bench_common.sh
21 source ..
/bench_plot.sh
23 ## CONFIGURATION OPTIONS ##
25 # Default number of times a command must be run with bench_command
26 # Can be overrided with 'the option -n'
29 xml
=bench_languages.xml
30 html
=bench_languages.html
34 echo "<html><body>" > $html
40 echo "run_bench: [options]* benchname"
41 echo " -v: verbose mode"
42 echo " -n count: number of execution for each bar (default: $count)"
43 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
44 echo " --fast: Run less and faster tests"
48 function system_info
()
50 ( # use a subshell to protect the set -x
55 git describe
--always HEAD
70 while [ "$stop" = false
]; do
72 -v
) verbose
=true
; system_info
; shift;;
74 -n
) count
="$2"; shift; shift;;
75 --dry
) dry_run
=true
; shift;;
76 --fast
) fast
=true
; shift;;
83 if test -z
"$NOTSKIPED"; then
85 echo "List of available benches:"
86 echo "* all: run all the benches"
90 test -f .
/nitc || ..
/..
/bin
/nitc ..
/..
/src
/nitc.nit
--semi
-global
-v
92 today
=`date +%Y-%m-%d_%H-%M-%S`
93 bdir
="languages.${today}.out"
94 rm -r
"$bdir" "./languages.out" 2> /dev
/null
95 ln -sf
"$bdir" "./languages.out"
97 ## EFFECTIVE BENCHS ##
99 function bench_language
()
102 skip_test
"$name" && return
104 basedir
="${bdir}/${name}"
111 if [ "$fast" = "true" ]; then
117 run_command .
/nitc benches
/$name.nit
-o
$basedir/$name.bin
&&
118 run_command
$basedir/$name.bin
$basedir "${t}_$b" "$b" "$s"
121 prepare_res
$basedir/$name-g
++.dat
"g++" "g++"
122 cppdir
="${basedir}/cpp"
123 test -d
$cppdir && for b
in $seq; do
124 run_command g
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.g++.bin" &&
125 bench_command
"$b" "" "${cppdir}/${t}_$b.g++.bin" $s
128 prepare_res
$basedir/$name-clang
++.dat
"clang++" "clang++"
129 test -d
$cppdir && for b
in $seq; do
130 run_command clang
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.clang++.bin" &&
131 bench_command
"$b" "" "${cppdir}/${t}_$b.clang++.bin" $s
134 prepare_res
$basedir/$name-java.dat
"java" "java"
135 javadir
="${basedir}/java"
136 test -d
$javadir && for b
in $seq; do
137 run_command javac
"${javadir}/${t}_$b.java" &&
138 bench_command
"$b" "" java
-cp "${javadir}/" "${t}_$b" $s
141 prepare_res
$basedir/$name-gcj.dat
"gcj" "gcj"
142 test -d
$javadir && for b
in $seq; do
143 run_command gcj
--main
=${t}_
$b -O2
"${javadir}/${t}_$b.java" -o
"${javadir}/${t}_$b.gcj.bin" &&
144 bench_command
"$b" "" "${javadir}/${t}_$b.gcj.bin" $s
147 prepare_res
$basedir/$name-scala.dat
"scala" "scala"
148 scaladir
="${basedir}/scala"
149 test -d
$scaladir && for b
in $seq; do
150 run_command scalac
"${scaladir}/${t}_$b.scala" -d
"${scaladir}" &&
151 bench_command
"$b" "" scala
-cp "${scaladir}/" "${t}_$b" $s
154 prepare_res
$basedir/$name-cs.dat
"c#" "c#"
155 csdir
="${basedir}/cs"
156 test -d
$csdir && for b
in $seq; do
157 run_command mcs
"$csdir/${t}_$b.cs" &&
158 bench_command
"$b" "" mono
"$csdir/${t}_$b.exe" $s
161 prepare_res
$basedir/$name-es.dat
"es" "es"
162 esdir
="${basedir}/es"
163 test -d
$esdir && for b
in $seq; do
164 run_command ec
-clean
-finalize
"$esdir/${t}_$b/app${t}_$b.e" &&
165 chmod +x
"app${t}_$b" &&
166 mv "app${t}_$b" "$esdir/${t}_$b.es.bin" &&
167 bench_command
"$b" "" "$esdir/${t}_$b.es.bin" $s
171 # SmartEiffel is so old...
172 prepare_res
$basedir/$name-se.dat
"se" "se"
173 sedir
="${basedir}/se"
174 test -d
$sedir && for b
in $seq; do
176 run_command se compile
-no_check app
${t}_
${b}_se.e
-loadpath
${t}_
${b}_se
-o
${t}_
$b.se.bin
178 bench_command
"$b" "" "$sedir/${t}_$b.se.bin" $s
182 prepare_res
$basedir/$name-python.dat
"python" "python"
183 pythondir
="${basedir}/python"
184 test -d
$pythondir && for b
in $seq; do
185 bench_command
"$b" "" "pypy" "$pythondir/${t}_$b.py" $s
188 nitdir
="${basedir}/nit"
189 prepare_res
$basedir/$name-nitc
-g.dat
"nitc-g" "nitc-g"
190 test -d
$nitdir && for b
in $seq; do
191 run_command .
/nitc
$nitdir/${t}_
$b.nit
--global
-o
"$nitdir/${t}_$b.nitc-g.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\"" &&
192 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-g.bin" $s
195 prepare_res
$basedir/$name-nitc
-sg.dat
"nitc-sg" "nitc-sg"
196 test -d
$nitdir && for b
in $seq; do
197 run_command .
/nitc
$nitdir/${t}_
$b.nit
--semi
-global
-o
"$nitdir/${t}_$b.nitc-sg.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\"" &&
198 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-sg.bin" $s
201 prepare_res
$basedir/$name-nitc
-s.dat
"nitc-s" "nitc-s"
202 test -d
$nitdir && for b
in $seq; do
203 run_command .
/nitc
$nitdir/${t}_
$b.nit
--separate
-o
"$nitdir/${t}_$b.nitc-s.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\"" &&
204 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-s.bin" $s
207 prepare_res
$basedir/$name-nitc
-su.dat
"nitc-su" "nitc-su"
208 test -d
$nitdir && for b
in $seq; do
209 run_command .
/nitc
$nitdir/${t}_
$b.nit
--separate
--no
-check
-covariance
-o
"$nitdir/${t}_$b.nitc-su.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\"" &&
210 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-su.bin" $s
213 prepare_res
$basedir/$name-nitc
-e.dat
"nitc-e" "nitc-e"
214 test -d
$nitdir && for b
in $seq; do
215 run_command .
/nitc
$nitdir/${t}_
$b.nit
--erasure
-o
"$nitdir/${t}_$b.nitc-e.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\"" &&
216 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-e.bin" $s
219 prepare_res
$basedir/$name-nitc
-eu.dat
"nitc-eu" "nitc-eu"
220 test -d
$nitdir && for b
in $seq; do
221 run_command .
/nitc
$nitdir/${t}_
$b.nit
--erasure
--no
-check
-covariance
--no
-check
-erasure
-cast
-o
"$nitdir/${t}_$b.nitc-eu.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\"" &&
222 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-eu.bin" $s
226 plot
$basedir/$name.gnu
229 for name
in benches
/*.nit
; do
230 n
=`basename $name .nit`
231 bench_language
$n < /dev
/null
234 echo "<h2>System Info</h2>" >> "$html"
235 system_info
2>&1 |
sed -e
's/$/<br>/;s|+\( .*\)|<h3>\1</h3>|' >> "$html"
237 if test -n
"$died"; then
238 echo "Some commands failed"