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_plot.sh
22 ## CONFIGURATION OPTIONS ##
24 # Default number of times a command must be run with bench_command
25 # Can be overrided with 'the option -n'
28 ### HELPER FUNCTIONS ##
36 # Run a single command multiple time and store the execution times
37 # in the current $res file.
39 # $1: title of the command
40 # $2: long desription of the command
41 # rest: the command to execute
42 function bench_command
()
44 if [ "$dry_run" = "true" ]; then return; fi
49 if test "$verbose" = true
; then outputopts
="/dev/stdout"; else outputopts
="/dev/null"; fi
51 echo "$title" > "$timeout"
52 echo "# $desc" >> "$timeout"
53 echo "\$ $@" >> "$timeout"
55 echo "** [$title] $desc **"
58 # Execute the commands $count times
59 for i
in `seq 1 "$count"`; do
60 (ulimit -t
300; /usr
/bin
/time -f
"%U" -o
"$timeout" -a
"$@") > $outputopts 2>&1 || die
"$1: failed"
65 line
=`compute_stats "$timeout"`
71 # Run a simple command witout storing the execution time
72 # Used to display command on verbose and skip long executions when dry_run is given
73 # $@ command to execute
74 function run_command
()
76 if [ "$dry_run" = "true" ]; then return; fi
78 (ulimit -t
180; "$@") || die
"$@: failed"
81 # Check if the test should be skiped according to its name
82 # $1: name of the test
83 # $2: description of the test
84 # $NOTSKIPED: arguments
87 if test -z
"$NOTSKIPED"; then
91 if test "$NOTSKIPED" = "all"; then
93 elif echo "$1" |
egrep "$NOTSKIPED" >/dev
/null
2>&1; then
94 : # Found one to execute
108 echo "run_bench: [options]* benchname"
109 echo " -v: verbose mode"
110 echo " -n count: number of execution for each bar (default: $count)"
111 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
112 echo " --fast: Run less and faster tests"
113 echo " -h: this help"
117 while [ "$stop" = false
]; do
119 -v
) verbose
=true
; shift;;
121 -n
) count
="$2"; shift; shift;;
122 --dry
) dry_run
=true
; shift;;
123 --fast
) fast
=true
; shift;;
130 if test -z
"$NOTSKIPED"; then
132 echo "List of available benches:"
133 echo "* all: run all the benches"
138 test -f .
/nitc_3 || .
/ncall.sh
-O
140 test -f .
/nitg || ..
/src
/nitc_3 ..
/src
/nitg.nit
-O
-v
142 ## EFFECTIVE BENCHS ##
144 function bench_language
()
147 skip_test
"$name" && return
149 basedir
="./${name}.out"
157 run_command .
/nitg languages
/$name.nit
-o
$basedir/$name.bin
158 run_command
$basedir/$name.bin
$basedir "${t}_$b" "$b"
161 prepare_res
$basedir/$name-g
++.dat
"g++" "g++"
162 cppdir
="${basedir}/cpp"
164 run_command g
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.g++.bin"
165 bench_command
"$b" "" "${cppdir}/${t}_$b.g++.bin" $s
168 prepare_res
$basedir/$name-clang
++.dat
"clang++" "clang++"
170 run_command clang
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.clang++.bin"
171 bench_command
"$b" "" "${cppdir}/${t}_$b.clang++.bin" $s
174 prepare_res
$basedir/$name-java.dat
"java" "java"
175 javadir
="${basedir}/java"
177 run_command javac
"${javadir}/${t}_$b.java"
178 bench_command
"$b" "" java
-cp "${javadir}/" "${t}_$b" $s
181 prepare_res
$basedir/$name-gcj.dat
"gcj" "gcj"
183 run_command gcj
--main
=${t}_
$b -O2
"${javadir}/${t}_$b.java" -o
"${javadir}/${t}_$b.gcj.bin"
184 bench_command
"$b" "" "${javadir}/${t}_$b.gcj.bin" $s
187 prepare_res
$basedir/$name-scala.dat
"scala" "scala"
188 scaladir
="${basedir}/scala"
190 run_command scalac
"${scaladir}/${t}_$b.scala" -d
"${scaladir}"
191 bench_command
"$b" "" scala
-cp "${scaladir}/" "${t}_$b" $s
194 prepare_res
$basedir/$name-cs.dat
"c#" "c#"
195 csdir
="${basedir}/cs"
197 run_command gmcs
"$csdir/${t}_$b.cs"
198 bench_command
"$b" "" mono
"$csdir/${t}_$b.exe" $s
201 prepare_res
$basedir/$name-es.dat
"es" "es"
202 esdir
="${basedir}/es"
205 run_command ec
-clean
-finalize
${t}_
$b/app
${t}_
$b.e
207 mv app
${t}_
$b ${t}_
$b.es.bin
209 bench_command
"$b" "" "$esdir/${t}_$b.es.bin" $s
212 prepare_res
$basedir/$name-se.dat
"se" "se"
213 sedir
="${basedir}/se"
216 run_command se compile
-no_check app
${t}_
${b}_se.e
-loadpath
${t}_
${b}_se
-o
${t}_
$b.se.bin
218 bench_command
"$b" "" "$sedir/${t}_$b.se.bin" $s
221 nitdir
="${basedir}/nit"
222 prepare_res
$nitdir/$name-nitg.dat
"nitg" "nitg"
224 run_command .
/nitg
$nitdir/${t}_
$b.nit
--global
-o
"$nitdir/${t}_$b.nitg.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
225 bench_command
"$b" "" "$nitdir/${t}_$b.nitg.bin" $s
228 prepare_res
$nitdir/$name-nitg
-s.dat
"nitg-s" "nitg-s"
230 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
-o
"$nitdir/${t}_$b.nitg-s.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
231 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-s.bin" $s
236 prepare_res
$nitdir/$name-$tg.dat
"$tg" "$tg"
238 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
--bm
-typing
-o
"$nitdir/${t}_$b.$tg.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
239 bench_command
"$b" "" "$nitdir/${t}_$b.$tg.bin" $s
243 prepare_res
$nitdir/$name-$tg.dat
"$tg" "$tg"
245 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
--phand
-typing
-o
"$nitdir/${t}_$b.$tg.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
246 bench_command
"$b" "" "$nitdir/${t}_$b.$tg.bin" $s
250 prepare_res
$nitdir/$name-$tg.dat
"$tg" "$tg"
252 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
--phmod
-typing
-o
"$nitdir/${t}_$b.$tg.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
253 bench_command
"$b" "" "$nitdir/${t}_$b.$tg.bin" $s
256 prepare_res
$nitdir/$name-nitg
-su.dat
"nitg-su" "nitg-su"
258 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
--no
-check
-covariance
-o
"$nitdir/${t}_$b.nitg-su.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
259 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-su.bin" $s
262 prepare_res
$nitdir/$name-nitg
-e.dat
"nitg-e" "nitg-e"
264 run_command .
/nitg
$nitdir/${t}_
$b.nit
--erasure
-o
"$nitdir/${t}_$b.nitg-e.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
265 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-e.bin" $s
268 prepare_res
$nitdir/$name-nitg
-eu.dat
"nitg-eu" "nitg-eu"
270 run_command .
/nitg
$nitdir/${t}_
$b.nit
--erasure
--no
-check
-covariance
--no
-check
-erasure
-cast
-o
"$nitdir/${t}_$b.nitg-eu.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
271 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-eu.bin" $s
275 plot
$basedir/$name.gnu
278 for name
in languages
/*.nit
; do
279 n
=`basename $name .nit`
283 if test -n
"$died"; then
284 echo "Some commands failed"