misc/vim: inform the user when no results are found
[nit.git] / benchmarks / bench_languages.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 # This shell script helps running benchmarks
17
18 # TODO: cleanup and libify the helper-parts
19
20 source ./bench_common.sh
21 source ./bench_plot.sh
22
23 ## CONFIGURATION OPTIONS ##
24
25 # Default number of times a command must be run with bench_command
26 # Can be overrided with 'the option -n'
27 count=2
28
29 ### HELPER FUNCTIONS ##
30
31 function die()
32 {
33 echo >&2 "error: $*"
34 died=1
35 }
36
37 ## HANDLE OPTIONS ##
38
39 function usage()
40 {
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"
46 echo " -h: this help"
47 }
48
49 stop=false
50 while [ "$stop" = false ]; do
51 case "$1" in
52 -v) verbose=true; shift;;
53 -h) usage; exit;;
54 -n) count="$2"; shift; shift;;
55 --dry) dry_run=true; shift;;
56 --fast) fast=true; shift;;
57 *) stop=true
58 esac
59 done
60
61 NOTSKIPED="$*"
62
63 if test -z "$NOTSKIPED"; then
64 usage
65 echo "List of available benches:"
66 echo "* all: run all the benches"
67 fi
68
69 ## COMPILE ENGINES
70 cd ../src
71 test -f ./nitc_3 || ./ncall.sh -O
72 cd ../benchmarks
73 test -f ./nitc || ../src/nitc_3 ../src/nitc.nit -O -v
74
75 ## EFFECTIVE BENCHS ##
76
77 function bench_language()
78 {
79 name="$1"
80 skip_test "$name" && return
81 rootdir=`pwd`
82 basedir="./${name}.out"
83
84 mkdir $basedir
85
86 t=t
87 s=20
88 seq="2 4 8"
89 for b in $seq; do
90 run_command ./nitc languages/$name.nit -o $basedir/$name.bin
91 run_command $basedir/$name.bin $basedir "${t}_$b" "$b"
92 done
93
94 prepare_res $basedir/$name-g++.dat "g++" "g++"
95 cppdir="${basedir}/cpp"
96 for b in $seq; do
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
99 done
100
101 prepare_res $basedir/$name-clang++.dat "clang++" "clang++"
102 for b in $seq; do
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
105 done
106
107 prepare_res $basedir/$name-java.dat "java" "java"
108 javadir="${basedir}/java"
109 for b in $seq; do
110 run_command javac "${javadir}/${t}_$b.java"
111 bench_command "$b" "" java -cp "${javadir}/" "${t}_$b" $s
112 done
113
114 prepare_res $basedir/$name-gcj.dat "gcj" "gcj"
115 for b in $seq; do
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
118 done
119
120 prepare_res $basedir/$name-scala.dat "scala" "scala"
121 scaladir="${basedir}/scala"
122 for b in $seq; do
123 run_command scalac "${scaladir}/${t}_$b.scala" -d "${scaladir}"
124 bench_command "$b" "" scala -cp "${scaladir}/" "${t}_$b" $s
125 done
126
127 prepare_res $basedir/$name-cs.dat "c#" "c#"
128 csdir="${basedir}/cs"
129 for b in $seq; do
130 run_command gmcs "$csdir/${t}_$b.cs"
131 bench_command "$b" "" mono "$csdir/${t}_$b.exe" $s
132 done
133
134 prepare_res $basedir/$name-es.dat "es" "es"
135 esdir="${basedir}/es"
136 for b in $seq; do
137 cd $esdir
138 run_command ec -clean -finalize ${t}_$b/app${t}_$b.e
139 chmod +x app${t}_$b
140 mv app${t}_$b ${t}_$b.es.bin
141 cd $rootdir
142 bench_command "$b" "" "$esdir/${t}_$b.es.bin" $s
143 done
144
145 prepare_res $basedir/$name-se.dat "se" "se"
146 sedir="${basedir}/se"
147 for b in $seq; do
148 cd $sedir
149 run_command se compile -no_check app${t}_${b}_se.e -loadpath ${t}_${b}_se -o ${t}_$b.se.bin
150 cd $rootdir
151 bench_command "$b" "" "$sedir/${t}_$b.se.bin" $s
152 done
153
154 nitdir="${basedir}/nit"
155 prepare_res $nitdir/$name-nitc.dat "nitc" "nitc"
156 for b in $seq; do
157 run_command ./nitc $nitdir/${t}_$b.nit --global -o "$nitdir/${t}_$b.nitc.bin" --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\""
158 bench_command "$b" "" "$nitdir/${t}_$b.nitc.bin" $s
159 done
160
161 prepare_res $nitdir/$name-nitc-s.dat "nitc-s" "nitc-s"
162 for b in $seq; do
163 run_command ./nitc $nitdir/${t}_$b.nit --separate -o "$nitdir/${t}_$b.nitc-s.bin" --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\""
164 bench_command "$b" "" "$nitdir/${t}_$b.nitc-s.bin" $s
165 done
166
167 <<XXX
168 prepare_res $nitdir/$name-nitc-su.dat "nitc-su" "nitc-su"
169 for b in $seq; do
170 run_command ./nitc $nitdir/${t}_$b.nit --separate --no-check-covariance -o "$nitdir/${t}_$b.nitc-su.bin" --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\""
171 bench_command "$b" "" "$nitdir/${t}_$b.nitc-su.bin" $s
172 done
173
174 prepare_res $nitdir/$name-nitc-e.dat "nitc-e" "nitc-e"
175 for b in $seq; do
176 run_command ./nitc $nitdir/${t}_$b.nit --erasure -o "$nitdir/${t}_$b.nitc-e.bin" --make-flags "CFLAGS=\"-g -O2 -DNOBOEHM\""
177 bench_command "$b" "" "$nitdir/${t}_$b.nitc-e.bin" $s
178 done
179
180 prepare_res $nitdir/$name-nitc-eu.dat "nitc-eu" "nitc-eu"
181 for b in $seq; do
182 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\""
183 bench_command "$b" "" "$nitdir/${t}_$b.nitc-eu.bin" $s
184 done
185 XXX
186
187 plot $basedir/$name.gnu
188 }
189
190 for name in languages/*.nit; do
191 n=`basename $name .nit`
192 bench_language $n
193 done
194
195 if test -n "$died"; then
196 echo "Some commands failed"
197 exit 1
198 fi
199 exit 0