cfedb897b079e7d062ff5f3985c2f9c48f66c6ea
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 ##
39 # Run standards benchs on a compiler command
41 # rest: command to run (executable + options)
42 function run_compiler
()
46 if test "$fast" = truetrue
; then
47 run_command
"$@" ..
/examples
/hello_world.nit
-o
"hello.$title.bin"
48 bench_command
"hello" "hello_world" "./hello.$title.bin"
49 elif test -n
"$fast"; then
50 run_command
"$@" ..
/src
/nitc.nit
-o
"nitc.$title.bin"
51 bench_command
"nitc-g" "nitc --global ../src/test_parser.nit" "./nitc.$title.bin" -v
--global
--no
-cc ..
/src
/test_parser.nit
52 run_command
"$@" ..
/src
/nit.nit
-o
"nit.$title.bin"
53 bench_command
"nit" "nit ../src/test_parser.nit ../src/location.nit" "./nit.$title.bin" -v ..
/src
/test_parser.nit
-- -n ..
/src
/location.nit
54 run_command
"$@" ..
/examples
/shoot
/src
/shoot_logic.nit
-o
"shoot.$title.bin"
55 bench_command
"shoot" "shoot_logic" "./shoot.$title.bin"
56 run_command
"$@" ..
/tests
/bench_bintree_gen.nit
-o
"bintrees.$title.bin"
57 bench_command
"bintrees" "bench_bintree_gen 16" "./bintrees.$title.bin" 16
59 run_command
"$@" ..
/src
/nitc.nit
-o
"nitc.$title.bin"
60 bench_command
"nitc-g" "nitc --global --no-cc ../src/nitls.nit" "./nitc.$title.bin" -v
--global
--no
-cc ..
/src
/nitls.nit
61 bench_command
"nitc-s" "nitc --separate ../src/nitc.nit" "./nitc.$title.bin" -v
--no
-cc
--separate ..
/src
/nitc.nit
62 run_command
"$@" ..
/src
/nit.nit
-o
"nit.$title.bin"
63 bench_command
"nit-queens" "nit queens.nit 8" "./nit.$title.bin" ..
/lib
/ai
/examples
/queens.nit
-q
8
64 bench_command
"nit-nitcc" "nit nitcc.nit calc.sablecc" "./nit.$title.bin" ..
/contrib
/nitcc
/src
/nitcc.nit ..
/contrib
/nitcc
/examples
/calc.sablecc
65 run_command
"$@" ..
/src
/nitdoc.nit
-o
"nitdoc.$title.bin"
66 rm -r out
2> /dev
/null
67 mkdir out
2> /dev
/null
68 bench_command
"nitdoc" "nitdoc ../src/nitls.nit" "./nitdoc.$title.bin" -v ..
/src
/nitls.nit
-d out
69 run_command
"$@" ..
/examples
/shoot
/src
/shoot_logic.nit
-o
"shoot.$title.bin"
70 bench_command
"shoot" "shoot_logic 15" "./shoot.$title.bin" 15
71 run_command
"$@" ..
/tests
/bench_bintree_gen.nit
-o
"bintrees.$title.bin"
72 bench_command
"bintrees" "bench_bintree_gen 17" "./bintrees.$title.bin" 17
73 #run_command "$@" "../contrib/pep8analysis/src/pep8analysis.nit" -o "pep8a.$title.bin"
74 #bench_command "pep8analisis" "bench_pep8analisis" "./pep8a.$title.bin" "../contrib/pep8analysis/tests/privat/"*.pep
75 run_command
"$@" "../lib/ai/examples/queens.nit" -o
"queens.$title.bin"
76 bench_command
"queens" "bench_queens 13" "./queens.$title.bin" 13
77 run_command
"$@" "../lib/ai/examples/puzzle.nit" -o
"puzzle.$title.bin"
78 bench_command
"puzzle" "puzzle 15-hard" "./puzzle.$title.bin" kleg.mondcafjhbi
79 run_command
"$@" "markdown/engines/nitmd/nitmd.nit" -o
"nitmd.$title.bin"
80 bench_command
"nitmd" "markdown" "./nitmd.$title.bin" markdown
/benches
/out
/mixed.md
80
83 rm -r
*.bin .nit_compile out
2> /dev
/null
90 echo "run_bench: [options]* benchname"
91 echo " -v: verbose mode"
92 echo " -n count: number of execution for each bar (default: $count)"
93 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
94 echo " --fast: Run less and faster tests"
95 echo " --html: Generate and HTML output"
100 while [ "$stop" = false
]; do
102 -v
) verbose
=true
; shift;;
104 -n
) count
="$2"; shift; shift;;
105 --dry
) dry_run
=true
; shift;;
106 --fast
) fast
=true
$fast; shift;;
107 --html
) html
="index.html"; echo >"$html" "<html><head></head><body>"; shift;;
112 xml
="bench_engines.xml"
113 echo "<testsuites><testsuite>" > "$xml"
117 if test -z
"$NOTSKIPED"; then
119 echo "List of available benches:"
120 echo "* all: run all the benches"
125 # get the bootstrapped nitc
128 if test -z
"$fast"; then
129 make -C markdown
/benches
130 make -C ..
/contrib
/nitcc
133 ## EFFECTIVE BENCHS ##
135 function bench_steps
()
138 skip_test
"$name" && return
139 prepare_res
"$name-nitc.dat" "nitc-g" "Various steps of nitc --global"
140 bench_command
"parse" "" .
/nitc
--global
--only
-parse ..
/src
/nitc.nit
141 bench_command
"metamodel" "" .
/nitc
--global
--only
-metamodel ..
/src
/nitc.nit
142 bench_command
"generate c" "" .
/nitc
--global
--no
-cc ..
/src
/nitc.nit
143 bench_command
"full" "" .
/nitc
--global ..
/src
/nitc.nit
-o
"nitc_nitc.bin"
145 prepare_res
"$name-nitc-s.dat" "nitc-s" "Various steps of nitc --separate"
146 bench_command
"parse" "" .
/nitc
--separate
--only
-parse ..
/src
/nitc.nit
147 bench_command
"metamodel" "" .
/nitc
--separate
--only
-metamodel ..
/src
/nitc.nit
148 bench_command
"generate c" "" .
/nitc
--separate
--no
-cc ..
/src
/nitc.nit
149 bench_command
"full" "" .
/nitc
--separate ..
/src
/nitc.nit
-o
"nitc_nitc-e.bin"
151 prepare_res
"$name-nitc-e.dat" "nitc-e" "Various steps of nitc --erasure"
152 bench_command
"parse" "" .
/nitc
--erasure
--only
-parse ..
/src
/nitc.nit
153 bench_command
"metamodel" "" .
/nitc
--erasure
--only
-metamodel ..
/src
/nitc.nit
154 bench_command
"generate c" "" .
/nitc
--erasure
--no
-cc ..
/src
/nitc.nit
155 bench_command
"full" "" .
/nitc
--erasure ..
/src
/nitc.nit
-o
"nitc_nitc-e.bin"
161 # $#: options to compare
162 function bench_nitc
-g_options
()
166 name
="$FUNCNAME-$tag"
167 skip_test
"$name" && return
168 prepare_res
"$name.dat" "no options" "nitc-g without options"
169 run_compiler
"nitc-g" .
/nitc
--global
171 if test "$1" = NOALL
; then
173 elif test -n
"$2"; then
174 prepare_res
"$name-all.dat" "all" "nitc-g with all options $@"
175 run_compiler
"nitc-g-$tag" .
/nitc
--global $@
180 prepare_res
"$name$ot.dat" "$opt" "nitc-g with option $opt"
181 run_compiler
"nitc-g$ot" .
/nitc
--global
$opt
186 bench_nitc
-g_options
"slower" --hardening
--no
-shortcut
-range
187 bench_nitc
-g_options
"nocheck" --no
-check
-null
--no
-check
-autocast
--no
-check
-attr
-isset
--no
-check
-covariance
--no
-check
-assert
189 function bench_nitc
-s_options
()
193 name
="$FUNCNAME-$tag"
194 skip_test
"$name" && return
195 prepare_res
"$name.dat" "no options" "nitc-s without options"
196 run_compiler
"nitc-s" .
/nitc
--separate
198 if test "$1" = NOALL
; then
200 elif test -n
"$2"; then
201 prepare_res
"$name-all.dat" "all" "nitc-s with all options $@"
202 run_compiler
"nitc-s-$tag" .
/nitc
--separate $@
207 prepare_res
"$name-$ot.dat" "$opt" "nitc-s with option $opt"
208 run_compiler
"nitc-s$ot" .
/nitc
--separate
$opt
213 bench_nitc
-s_options
"slower" --hardening
--no
-shortcut
-equal
--no
-union
-attribute
--no
-shortcut
-range
--no
-inline
-intern
"--no-gcc-directive likely --no-gcc-directive noreturn" "--no-tag-primitives"
214 bench_nitc
-s_options
"nocheck" --no
-check
-null
--no
-check
-autocast
--no
-check
-attr
-isset
--no
-check
-covariance
--no
-check
-assert
215 bench_nitc
-s_options
"faster" --skip
-dead
-methods
--inline
-coloring
-numbers
--inline
-some
-methods
--direct
-call
-monomorph
"--inline-some-methods --direct-call-monomorph" ""
217 function bench_nitc
-e_options
()
221 name
="$FUNCNAME-$tag"
222 skip_test
"$name" && return
223 prepare_res
"$name.dat" "no options" "nitc-e without options"
224 run_compiler
"nitc-e" .
/nitc
--erasure
226 if test "$1" = NOALL
; then
228 elif test -n
"$2"; then
229 prepare_res
"$name-all.dat" "all" "nitc-e with all options $@"
230 run_compiler
"nitc-e-$tag" .
/nitc
--erasure $@
235 prepare_res
"$name$ot.dat" "$opt" "nitc-e with option $opt"
236 run_compiler
"nitc-e$ot" .
/nitc
--erasure
$opt
241 bench_nitc
-e_options
"slower" --hardening
--no
-shortcut
-equal
--no
-union
-attribute
--no
-shortcut
-range
--no
-inline
-intern
242 bench_nitc
-e_options
"nocheck" --no
-check
-null
--no
-check
-autocast
--no
-check
-attr
-isset
--no
-check
-covariance
--no
-check
-assert
--no
-check
-erasure
-cast
243 bench_nitc
-e_options
"faster" --skip
-dead
-methods
--inline
-coloring
-numbers
--inline
-some
-methods
--direct
-call
-monomorph
--rta
245 function bench_engines
()
248 skip_test
"$name" && return
249 prepare_res
"$name-nitc-s.dat" "nitc-s" "nitc with --separate"
250 run_compiler
"nitc-s" .
/nitc
--separate
251 prepare_res
"$name-nitc-e.dat" "nitc-e" "nitc with --erasure"
252 run_compiler
"nitc-e" .
/nitc
--erasure
253 prepare_res
"$name-nitc-sg.dat" "nitc-sg" "nitc with --separate --semi-global"
254 run_compiler
"nitc-sg" .
/nitc
--separate
--semi
-global
255 prepare_res
"$name-nitc-eg.dat" "nitc-eg" "nitc with --erasure --semi-global"
256 run_compiler
"nitc-eg" .
/nitc
--erasure
--semi
-global
257 prepare_res
"$name-nitc-egt.dat" "nitc-egt" "nitc with --erasure --semi-global --rta"
258 run_compiler
"nitc-egt" .
/nitc
--erasure
--semi
-global
--rta
259 prepare_res
"$name-nitc-g.dat" "nitc-g" "nitc with --global"
260 run_compiler
"nitc-g" .
/nitc
--global
265 function bench_nitc
-e_gc
()
268 skip_test
"$name" && return
269 prepare_res
"$name-nitc-e.dat" "nitc-e" "nitc with --erasure"
270 run_compiler
"nitc-e" .
/nitc
--erasure
271 prepare_res
"$name-nitc-e-malloc.dat" "nitc-e-malloc" "nitc with --erasure and malloc"
272 NIT_GC_OPTION
="malloc" run_compiler
"nitc-e-malloc" .
/nitc
--erasure
273 prepare_res
"$name-nitc-e-large.dat" "nitc-e-large" "nitc with --erasure and large"
274 NIT_GC_OPTION
="large" run_compiler
"nitc-e-large" .
/nitc
--erasure
279 function bench_cc_nitc
-e
()
282 skip_test
"$name" && return
283 for o
in "gcc0:CC=\"ccache gcc\" CFLAGS=-O0" "cl0:CC=\"ccache clang\" CFLAGS=-O0" "gccs:CC=\"ccache gcc\" CFLAGS=-Os" "cls:CC=\"ccache clang\" CFLAGS=-Os" "gcc2:CC=\"ccache gcc\" CFLAGS=-O2" "cl2:CC=\"ccache clang\" CFLAGS=-O2" "gcc3:CC=\"ccache gcc\" CFLAGS=-O3" "cl3:CC=\"ccache clang\" CFLAGS=-O3"; do
284 f
=`echo "$o" | cut -f1 -d:`
285 o
=`echo "$o" | cut -f2 -d:`
286 prepare_res
"$name-nitc-e-$f.dat" "nitc-e-$f" "nitc with --erasure --make-flags $o"
287 run_compiler
"nitc-e-$f" .
/nitc
--erasure
--make-flags
"$o"
293 function bench_policy
()
296 skip_test
"$name" && return
297 prepare_res
"$name-nitc-s.dat" "nitc-s" "nitc with --separate"
298 run_compiler
"nitc-s" .
/nitc
--separate
299 prepare_res
"$name-nitc-e.dat" "nitc-e" "nitc with --erasure"
300 run_compiler
"nitc-e" .
/nitc
--erasure
301 prepare_res
"$name-nitc-su.dat" "nitc-su" "nitc with --separate --no-check-covariance"
302 run_compiler
"nitc-su" .
/nitc
--separate
--no
-check
-covariance
303 prepare_res
"$name-nitc-eu.dat" "nitc-eu" "nitc with --erasure --no-check-covariance --no-check-erasure-cast"
304 run_compiler
"nitc-eu" .
/nitc
--erasure
--no
-check
-covariance
--no
-check
-erasure
-cast
309 function bench_nullables
()
312 skip_test
"$name" && return
313 prepare_res
"$name-nitc.dat" "nitc" "nitc no options"
314 run_compiler
"nitc" .
/nitc
--separate
315 prepare_res
"$name-nitc-ni.dat" "nitc-ni" "nitc --no-check-attr-isset"
316 run_compiler
"nitc" .
/nitc
--separate
--no
-check
-attr
-isset
317 prepare_res
"$name-nitc-nu.dat" "nitc-nu" "nitc --no-union-attribute"
318 run_compiler
"nitc" .
/nitc
--separate
--no
-union
-attribute
319 prepare_res
"$name-nitc-nu-ni.dat" "nitc-nu-ni" "nitc --no-union-attribute --no-check-attr-isset"
320 run_compiler
"nitc" .
/nitc
--separate
--no
-union
-attribute
--no
-check
-attr
-isset
325 function bench_compilation_time
328 skip_test
"$name" && return
329 prepare_res
"$name-nitc-g.dat" "nitc-g" "nitc --global"
330 for i
in ..
/examples
/hello_world.nit ..
/src
/test_parser.nit ..
/src
/nitc.nit
; do
331 bench_command
`basename "$i" .nit` "" .
/nitc
--global
"$i" --no
-cc
333 prepare_res
"$name-nitc-s.dat" "nitc-s" "nitc --separate"
334 for i
in ..
/examples
/hello_world.nit ..
/src
/test_parser.nit ..
/src
/nitc.nit
; do
335 bench_command
`basename "$i" .nit` "" .
/nitc
--separate
"$i" --no
-cc
337 prepare_res
"$name-nitc-e.dat" "nitc-e" "nitc --erasure"
338 for i
in ..
/examples
/hello_world.nit ..
/src
/test_parser.nit ..
/src
/nitc.nit
; do
339 bench_command
`basename "$i" .nit` "" .
/nitc
--erasure
"$i" --no
-cc
343 bench_compilation_time
345 function bench_linkboost
()
348 skip_test
"$name" && return
349 prepare_res
"$name-nitc-st.dat" "nitc-st" "nitc with --separate --trampoline-call"
350 run_compiler
"nitc-st" .
/nitc
--separate
--trampoline
-call
351 prepare_res
"$name-nitc-s.dat" "nitc-s" "nitc with --separate"
352 run_compiler
"nitc-s" .
/nitc
--separate
353 prepare_res
"$name-nitc-sc.dat" "nitc-sc" "nitc with --separate --colors-are-symbols"
354 run_compiler
"nitc-sc" .
/nitc
--separate
--colors
-are
-symbols
355 prepare_res
"$name-nitc-sct.dat" "nitc-sct" "nitc with --separate --colors-are-symbols --trampoline-call"
356 run_compiler
"nitc-sct" .
/nitc
--separate
--colors
-are
-symbols
--trampoline
-call
357 prepare_res
"$name-nitc-sl.dat" "nitc-sl" "nitc with --separate --link-boost"
358 run_compiler
"nitc-scts" .
/nitc
--separate
--link
-boost
359 prepare_res
"$name-nitc-scgc.dat" "nitc-scgc" "nitc with --separate --colors-are-symbols --guard-call"
360 run_compiler
"nitc-scgc" .
/nitc
--separate
--colors
-are
-symbols
--guard
-call
361 prepare_res
"$name-nitc-scd.dat" "nitc-scd" "nitc with --separate --colors-are-symbols --direct-call-monomorph0"
362 run_compiler
"nitc-scd" .
/nitc
--separate
--colors
-are
-symbols
--direct
-call
-monomorph0
367 function bench_call_monomorph
()
370 skip_test
"$name" && return
371 prepare_res
"$name-nitc.dat" "nitc" "nitc with --separate"
372 run_compiler
"nitc" .
/nitc
373 prepare_res
"$name-nitc-d0.dat" "nitc-d0" "nitc with --separate --direct-call-monomorph0"
374 run_compiler
"nitc-d0" .
/nitc
--direct
-call
-monomorph0
375 prepare_res
"$name-nitc-d1.dat" "nitc-d" "nitc with --separate --direct-call-monomorph"
376 run_compiler
"nitc-d1" .
/nitc
--direct
-call
-monomorph
377 prepare_res
"$name-nitc-d2.dat" "nitc-d2" "nitc with --separate --direct-call-monomorph2"
378 run_compiler
"nitc-d2" .
/nitc
--direct
-call
-monomorph
--direct
-call
-monomorph0
383 if test -n
"$html"; then
384 echo >>"$html" "</body></html>"
387 echo >>"$xml" "</testsuite></testsuites>"
389 if test -n
"$died"; then
390 echo "Some commands failed"