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 ### HELPER FUNCTIONS ##
41 echo "run_bench: [options]* benchname"
42 echo " -v: verbose mode"
43 echo " -n count: number of execution for each bar (default: $count)"
44 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
45 echo " --fast: Run less and faster tests"
50 while [ "$stop" = false
]; do
52 -v
) verbose
=true
; shift;;
54 -n
) count
="$2"; shift; shift;;
55 --dry
) dry_run
=true
; shift;;
56 --fast
) fast
=true
; shift;;
63 if test -z
"$NOTSKIPED"; then
65 echo "List of available benches:"
66 echo "* all: run all the benches"
71 test -f .
/nitc_3 || .
/ncall.sh
-O
73 test -f .
/nitg || ..
/src
/nitc_3 ..
/src
/nitg.nit
-O
-v
75 ## EFFECTIVE BENCHS ##
77 function bench_language
()
80 skip_test
"$name" && return
82 basedir
="./${name}.out"
90 run_command .
/nitg languages
/$name.nit
-o
$basedir/$name.bin
91 run_command
$basedir/$name.bin
$basedir "${t}_$b" "$b"
94 prepare_res
$basedir/$name-g
++.dat
"g++" "g++"
95 cppdir
="${basedir}/cpp"
97 run_command g
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.g++.bin"
98 bench_command
"$b" "" "${cppdir}/${t}_$b.g++.bin" $s
101 prepare_res
$basedir/$name-clang
++.dat
"clang++" "clang++"
103 run_command clang
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.clang++.bin"
104 bench_command
"$b" "" "${cppdir}/${t}_$b.clang++.bin" $s
107 prepare_res
$basedir/$name-java.dat
"java" "java"
108 javadir
="${basedir}/java"
110 run_command javac
"${javadir}/${t}_$b.java"
111 bench_command
"$b" "" java
-cp "${javadir}/" "${t}_$b" $s
114 prepare_res
$basedir/$name-gcj.dat
"gcj" "gcj"
116 run_command gcj
--main
=${t}_
$b -O2
"${javadir}/${t}_$b.java" -o
"${javadir}/${t}_$b.gcj.bin"
117 bench_command
"$b" "" "${javadir}/${t}_$b.gcj.bin" $s
120 prepare_res
$basedir/$name-scala.dat
"scala" "scala"
121 scaladir
="${basedir}/scala"
123 run_command scalac
"${scaladir}/${t}_$b.scala" -d
"${scaladir}"
124 bench_command
"$b" "" scala
-cp "${scaladir}/" "${t}_$b" $s
127 prepare_res
$basedir/$name-cs.dat
"c#" "c#"
128 csdir
="${basedir}/cs"
130 run_command gmcs
"$csdir/${t}_$b.cs"
131 bench_command
"$b" "" mono
"$csdir/${t}_$b.exe" $s
134 prepare_res
$basedir/$name-es.dat
"es" "es"
135 esdir
="${basedir}/es"
138 run_command ec
-clean
-finalize
${t}_
$b/app
${t}_
$b.e
140 mv app
${t}_
$b ${t}_
$b.es.bin
142 bench_command
"$b" "" "$esdir/${t}_$b.es.bin" $s
145 prepare_res
$basedir/$name-se.dat
"se" "se"
146 sedir
="${basedir}/se"
149 run_command se compile
-no_check app
${t}_
${b}_se.e
-loadpath
${t}_
${b}_se
-o
${t}_
$b.se.bin
151 bench_command
"$b" "" "$sedir/${t}_$b.se.bin" $s
154 nitdir
="${basedir}/nit"
155 prepare_res
$nitdir/$name-nitg.dat
"nitg" "nitg"
157 run_command .
/nitg
$nitdir/${t}_
$b.nit
--global
-o
"$nitdir/${t}_$b.nitg.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
158 bench_command
"$b" "" "$nitdir/${t}_$b.nitg.bin" $s
161 prepare_res
$nitdir/$name-nitg
-s.dat
"nitg-s" "nitg-s"
163 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
-o
"$nitdir/${t}_$b.nitg-s.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
164 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-s.bin" $s
168 prepare_res
$nitdir/$name-nitg
-su.dat
"nitg-su" "nitg-su"
170 run_command .
/nitg
$nitdir/${t}_
$b.nit
--separate
--no
-check
-covariance
-o
"$nitdir/${t}_$b.nitg-su.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
171 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-su.bin" $s
174 prepare_res
$nitdir/$name-nitg
-e.dat
"nitg-e" "nitg-e"
176 run_command .
/nitg
$nitdir/${t}_
$b.nit
--erasure
-o
"$nitdir/${t}_$b.nitg-e.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
177 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-e.bin" $s
180 prepare_res
$nitdir/$name-nitg
-eu.dat
"nitg-eu" "nitg-eu"
182 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\""
183 bench_command
"$b" "" "$nitdir/${t}_$b.nitg-eu.bin" $s
187 plot
$basedir/$name.gnu
190 for name
in languages
/*.nit
; do
191 n
=`basename $name .nit`
195 if test -n
"$died"; then
196 echo "Some commands failed"