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'
33 echo "run_bench: [options]* benchname"
34 echo " -v: verbose mode"
35 echo " -n count: number of execution for each bar (default: $count)"
36 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
37 echo " --fast: Run less and faster tests"
42 while [ "$stop" = false
]; do
44 -v
) verbose
=true
; shift;;
46 -n
) count
="$2"; shift; shift;;
47 --dry
) dry_run
=true
; shift;;
48 --fast
) fast
=true
; shift;;
55 if test -z
"$NOTSKIPED"; then
57 echo "List of available benches:"
58 echo "* all: run all the benches"
63 test -f .
/nitc_3 || .
/ncall.sh
-O
65 test -f .
/nitc || ..
/src
/nitc_3 ..
/src
/nitc.nit
-O
-v
67 ## EFFECTIVE BENCHS ##
69 function bench_language
()
72 skip_test
"$name" && return
74 basedir
="./${name}.out"
82 run_command .
/nitc languages
/$name.nit
-o
$basedir/$name.bin
83 run_command
$basedir/$name.bin
$basedir "${t}_$b" "$b"
86 prepare_res
$basedir/$name-g
++.dat
"g++" "g++"
87 cppdir
="${basedir}/cpp"
89 run_command g
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.g++.bin"
90 bench_command
"$b" "" "${cppdir}/${t}_$b.g++.bin" $s
93 prepare_res
$basedir/$name-clang
++.dat
"clang++" "clang++"
95 run_command clang
++ "${cppdir}/${t}_$b.cpp" -O2
-o
"${cppdir}/${t}_$b.clang++.bin"
96 bench_command
"$b" "" "${cppdir}/${t}_$b.clang++.bin" $s
99 prepare_res
$basedir/$name-java.dat
"java" "java"
100 javadir
="${basedir}/java"
102 run_command javac
"${javadir}/${t}_$b.java"
103 bench_command
"$b" "" java
-cp "${javadir}/" "${t}_$b" $s
106 prepare_res
$basedir/$name-gcj.dat
"gcj" "gcj"
108 run_command gcj
--main
=${t}_
$b -O2
"${javadir}/${t}_$b.java" -o
"${javadir}/${t}_$b.gcj.bin"
109 bench_command
"$b" "" "${javadir}/${t}_$b.gcj.bin" $s
112 prepare_res
$basedir/$name-scala.dat
"scala" "scala"
113 scaladir
="${basedir}/scala"
115 run_command scalac
"${scaladir}/${t}_$b.scala" -d
"${scaladir}"
116 bench_command
"$b" "" scala
-cp "${scaladir}/" "${t}_$b" $s
119 prepare_res
$basedir/$name-cs.dat
"c#" "c#"
120 csdir
="${basedir}/cs"
122 run_command gmcs
"$csdir/${t}_$b.cs"
123 bench_command
"$b" "" mono
"$csdir/${t}_$b.exe" $s
126 prepare_res
$basedir/$name-es.dat
"es" "es"
127 esdir
="${basedir}/es"
130 run_command ec
-clean
-finalize
${t}_
$b/app
${t}_
$b.e
132 mv app
${t}_
$b ${t}_
$b.es.bin
134 bench_command
"$b" "" "$esdir/${t}_$b.es.bin" $s
137 prepare_res
$basedir/$name-se.dat
"se" "se"
138 sedir
="${basedir}/se"
141 run_command se compile
-no_check app
${t}_
${b}_se.e
-loadpath
${t}_
${b}_se
-o
${t}_
$b.se.bin
143 bench_command
"$b" "" "$sedir/${t}_$b.se.bin" $s
146 nitdir
="${basedir}/nit"
147 prepare_res
$nitdir/$name-nitc.dat
"nitc" "nitc"
149 run_command .
/nitc
$nitdir/${t}_
$b.nit
--global
-o
"$nitdir/${t}_$b.nitc.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
150 bench_command
"$b" "" "$nitdir/${t}_$b.nitc.bin" $s
153 prepare_res
$nitdir/$name-nitc
-s.dat
"nitc-s" "nitc-s"
155 run_command .
/nitc
$nitdir/${t}_
$b.nit
--separate
-o
"$nitdir/${t}_$b.nitc-s.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
156 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-s.bin" $s
160 prepare_res
$nitdir/$name-nitc
-su.dat
"nitc-su" "nitc-su"
162 run_command .
/nitc
$nitdir/${t}_
$b.nit
--separate
--no
-check
-covariance
-o
"$nitdir/${t}_$b.nitc-su.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
163 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-su.bin" $s
166 prepare_res
$nitdir/$name-nitc
-e.dat
"nitc-e" "nitc-e"
168 run_command .
/nitc
$nitdir/${t}_
$b.nit
--erasure
-o
"$nitdir/${t}_$b.nitc-e.bin" --make-flags
"CFLAGS=\"-g -O2 -DNOBOEHM\""
169 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-e.bin" $s
172 prepare_res
$nitdir/$name-nitc
-eu.dat
"nitc-eu" "nitc-eu"
174 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\""
175 bench_command
"$b" "" "$nitdir/${t}_$b.nitc-eu.bin" $s
179 plot
$basedir/$name.gnu
182 for name
in languages
/*.nit
; do
183 n
=`basename $name .nit`
187 if test -n
"$died"; then
188 echo "Some commands failed"