X-Git-Url: http://nitlanguage.org diff --git a/benchmarks/bench_engines.sh b/benchmarks/bench_engines.sh index 89dc5ae..8e7f591 100755 --- a/benchmarks/bench_engines.sh +++ b/benchmarks/bench_engines.sh @@ -17,6 +17,7 @@ # TODO: cleanup and libify the helper-parts +source ./bench_common.sh source ./bench_plot.sh ## CONFIGURATION OPTIONS ## @@ -25,86 +26,6 @@ source ./bench_plot.sh # Can be overrided with 'the option -n' count=2 -pep8analysis=../../pep8analysis - -### HELPER FUNCTIONS ## - -function die() -{ - echo >&2 "error: $*" - died=1 -} - -# Run a single command multiple time and store the execution times -# in the current $res file. -# -# $1: title of the command -# $2: long desription of the command -# rest: the command to execute -function bench_command() -{ - if [ "$dry_run" = "true" ]; then return; fi - local title="$1" - local desc="$2" - shift - shift - if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi - timeout="time.out" - echo "$title" > "$timeout" - echo "# $desc" >> "$timeout" - echo "\$ $@" >> "$timeout" - echo - echo "** [$title] $desc **" - echo " $ $@" - - # Execute the commands $count times - for i in `seq 1 "$count"`; do - /usr/bin/time -f "%U" -o "$timeout" -a "$@" > $outputopts 2>&1 || die "$1: failed" - echo -n "$i. " - tail -n 1 "$timeout" - done - - line=`compute_stats "$timeout"` - echo "$line ($res)" - echo $line >> "$res" -} - -# Run a simble command witout storing the execution time -# Used to display command on verbose and skip long executions when dry_run is given -# $@ command to execute -function run_command() -{ - if [ "$dry_run" = "true" ]; then return; fi - echo " $ $@" - "$@" || die "$@: failed" -} - -# Check if the test should be skiped according to its name -# $1: name of the test -# $2: description of the test -# $NOTSKIPED: arguments -function skip_test() -{ - if test -z "$NOTSKIPED"; then - echo "* $1" - return 0 - fi - if test "$NOTSKIPED" = "all"; then - : # Execute anyway - elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then - : # Found one to execute - else - return 0 - fi - if test -n "$html"; then - echo >>"$html" "

$1

" - fi - echo "*" - echo "* $1 *****" - echo "*" - return 1 -} - # HELPER FOR NIT # # Run standards benchs on a compiler command @@ -114,9 +35,12 @@ function run_compiler() { local title=$1 shift - if test -n "$fast"; then - run_command "$@" ../src/nitg.nit -o "nitg.$title.bin" - bench_command "nitg-g" "nitg --global ../src/test_parser.nit" "./nitg.$title.bin" -v --global --no-cc ../src/test_parser.nit + if test "$fast" = truetrue; then + run_command "$@" ../examples/hello_world.nit -o "hello.$title.bin" + bench_command "hello" "hello_world" "./hello.$title.bin" + elif test -n "$fast"; then + run_command "$@" ../src/nitc.nit -o "nitc.$title.bin" + bench_command "nitc-g" "nitc --global ../src/test_parser.nit" "./nitc.$title.bin" -v --global --no-cc ../src/test_parser.nit run_command "$@" ../src/nit.nit -o "nit.$title.bin" bench_command "nit" "nit ../src/test_parser.nit ../src/location.nit" "./nit.$title.bin" -v ../src/test_parser.nit -- -n ../src/location.nit run_command "$@" ../examples/shoot/src/shoot_logic.nit -o "shoot.$title.bin" @@ -124,20 +48,37 @@ function run_compiler() run_command "$@" ../tests/bench_bintree_gen.nit -o "bintrees.$title.bin" bench_command "bintrees" "bench_bintree_gen 16" "./bintrees.$title.bin" 16 else - run_command "$@" ../src/nitg.nit -o "nitg.$title.bin" - bench_command "nitg-g" "nitg --global --no-cc ../src/nitmetrics.nit" "./nitg.$title.bin" -v --global --no-cc ../src/nitmetrics.nit - bench_command "nitg-s" "nitg --separate ../src/nitg.nit" "./nitg.$title.bin" -v --no-cc --separate ../src/nitg.nit + rm -r out 2> /dev/null + mkdir out 2> /dev/null + run_command "$@" ../src/nitc.nit -o "nitc.$title.bin" + bench_command "nitc-g" "nitc --global --no-cc ../src/nitls.nit" "./nitc.$title.bin" -v --global --no-cc ../src/nitls.nit + bench_command "nitc-s" "nitc --separate ../src/nitc.nit" "./nitc.$title.bin" -v --no-cc --separate ../src/nitc.nit run_command "$@" ../src/nit.nit -o "nit.$title.bin" - bench_command "nit" "nit ../src/test_parser.nit ../src/rapid_type_analysis.nit" "./nit.$title.bin" -v ../src/test_parser.nit -- -n ../src/rapid_type_analysis.nit + bench_command "nit-queens" "nit queens.nit 8" "./nit.$title.bin" ../lib/ai/examples/queens.nit -q 8 + bench_command "nit-nitcc" "nit nitcc.nit calc.sablecc" "./nit.$title.bin" ../contrib/nitcc/src/nitcc.nit ../contrib/nitcc/examples/calc.sablecc + rm calc* 2> /dev/null # remove generated cruft + run_command "$@" ../src/nitdoc.nit -o "nitdoc.$title.bin" + bench_command "nitdoc" "nitdoc ../src/nitls.nit" "./nitdoc.$title.bin" -v ../src/nitls.nit -d out + run_command "$@" ../src/nitlight.nit -o "nitlight.$title.bin" + bench_command "nitlight" "nitlight ../lib/[a-f]*/" "./nitlight.$title.bin" ../lib/[a-f]*/ -d out run_command "$@" ../examples/shoot/src/shoot_logic.nit -o "shoot.$title.bin" - bench_command "shoot" "shoot_logic 30" "./shoot.$title.bin" 30 + bench_command "shoot" "shoot_logic 15" "./shoot.$title.bin" 15 run_command "$@" ../tests/bench_bintree_gen.nit -o "bintrees.$title.bin" - bench_command "bintrees" "bench_bintree_gen 18" "./bintrees.$title.bin" 18 - if test -f "$pep8analysis/src/pep8analysis.nit"; then - run_command "$@" "$pep8analysis/src/pep8analysis.nit" -I "$pep8analysis/lib" -o "pep8a.$title.bin" - bench_command "pep8analisis" "bench_bintree_gen 18" "./pep8a.$title.bin" "$pep8analysis/tests/privat/"*.pep - fi + bench_command "bintrees" "bench_bintree_gen 17" "./bintrees.$title.bin" 17 + #run_command "$@" "../contrib/pep8analysis/src/pep8analysis.nit" -o "pep8a.$title.bin" + #bench_command "pep8analisis" "bench_pep8analisis" "./pep8a.$title.bin" "../contrib/pep8analysis/tests/privat/"*.pep + run_command "$@" "../lib/ai/examples/queens.nit" -o "queens.$title.bin" + bench_command "queens" "bench_queens 13" "./queens.$title.bin" 13 + run_command "$@" "../lib/ai/examples/puzzle.nit" -o "puzzle.$title.bin" + bench_command "puzzle" "puzzle 15-hard" "./puzzle.$title.bin" kleg.mondcafjhbi + run_command "$@" "markdown/engines/nitmd/nitmd.nit" -o "nitmd.$title.bin" + bench_command "nitmd" "markdown" "./nitmd.$title.bin" markdown/benches/out/mixed.md 80 + run_command "$@" ../contrib/jwrapper/src/jwrapper.nit -o "jwrapper.$title.bin" + bench_command "jwrapper" "jwrapper ant.jar" "./jwrapper.$title.bin" /usr/share/java/ant.jar -o out/ant_jar.nit + rm -r tmp 2> /dev/null # remove jwrapper output directory fi + + rm -r *.bin out 2> /dev/null } ## HANDLE OPTIONS ## @@ -149,7 +90,6 @@ function usage() echo " -n count: number of execution for each bar (default: $count)" echo " --dry: Do not run the commands, just reuse the data and generate the graph" echo " --fast: Run less and faster tests" - echo " --html: Generate and HTML output" echo " -h: this help" } @@ -160,12 +100,18 @@ while [ "$stop" = false ]; do -h) usage; exit;; -n) count="$2"; shift; shift;; --dry) dry_run=true; shift;; - --fast) fast=true; shift;; - --html) html="index.html"; echo >"$html" ""; shift;; + --fast) fast=true$fast; shift;; + --html) shift;; # Deprecated *) stop=true esac done +html="index.html" +echo >"$html" "" + +xml="bench_engines.xml" +echo "" > "$xml" + NOTSKIPED="$*" if test -z "$NOTSKIPED"; then @@ -176,8 +122,14 @@ fi ## COMPILE ENGINES -# force to use the last nitg, not the bootstraped one -test -f ./nitg || ../bin/nitg ../src/nitg.nit -v +# get the bootstrapped nitc +cp ../bin/nitc . + +if test -z "$fast"; then + make -C markdown/benches + make -C ../contrib/nitcc + make pre-build -C ../contrib/jwrapper +fi ## EFFECTIVE BENCHS ## @@ -185,193 +137,146 @@ function bench_steps() { name="$FUNCNAME" skip_test "$name" && return - prepare_res "$name-nitg.dat" "nitg-g" "Various steps of nitg --global" - bench_command "parse" "" ./nitg --global --only-parse ../src/nitg.nit - bench_command "metamodel" "" ./nitg --global --only-metamodel ../src/nitg.nit - bench_command "generate c" "" ./nitg --global --no-cc ../src/nitg.nit - bench_command "full" "" ./nitg --global ../src/nitg.nit -o "nitg_nitg.bin" - - prepare_res "$name-nitg-s.dat" "nitg-s" "Various steps of nitg --separate" - bench_command "parse" "" ./nitg --separate --only-parse ../src/nitg.nit - bench_command "metamodel" "" ./nitg --separate --only-metamodel ../src/nitg.nit - bench_command "generate c" "" ./nitg --separate --no-cc ../src/nitg.nit - bench_command "full" "" ./nitg --separate ../src/nitg.nit -o "nitg_nitg-e.bin" - - prepare_res "$name-nitg-e.dat" "nitg-e" "Various steps of nitg --erasure" - bench_command "parse" "" ./nitg --erasure --only-parse ../src/nitg.nit - bench_command "metamodel" "" ./nitg --erasure --only-metamodel ../src/nitg.nit - bench_command "generate c" "" ./nitg --erasure --no-cc ../src/nitg.nit - bench_command "full" "" ./nitg --erasure ../src/nitg.nit -o "nitg_nitg-e.bin" + prepare_res "$name-nitc.dat" "nitc-g" "Various steps of nitc --global" + bench_command "parse" "" ./nitc --global --only-parse ../src/nitc.nit + bench_command "metamodel" "" ./nitc --global --only-metamodel ../src/nitc.nit + bench_command "generate c" "" ./nitc --global --no-cc ../src/nitc.nit + bench_command "full" "" ./nitc --global ../src/nitc.nit -o "nitc_nitc.bin" + + prepare_res "$name-nitc-s.dat" "nitc-s" "Various steps of nitc --separate" + bench_command "parse" "" ./nitc --separate --only-parse ../src/nitc.nit + bench_command "metamodel" "" ./nitc --separate --only-metamodel ../src/nitc.nit + bench_command "generate c" "" ./nitc --separate --no-cc ../src/nitc.nit + bench_command "full" "" ./nitc --separate ../src/nitc.nit -o "nitc_nitc-e.bin" + + prepare_res "$name-nitc-e.dat" "nitc-e" "Various steps of nitc --erasure" + bench_command "parse" "" ./nitc --erasure --only-parse ../src/nitc.nit + bench_command "metamodel" "" ./nitc --erasure --only-metamodel ../src/nitc.nit + bench_command "generate c" "" ./nitc --erasure --no-cc ../src/nitc.nit + bench_command "full" "" ./nitc --erasure ../src/nitc.nit -o "nitc_nitc-e.bin" plot "$name.gnu" } bench_steps -# $#: options to compare -function bench_nitg-g_options() +# Simple script to compare various options on nitc +# +# usage: *name* *common* [NOALL] *options*... +# +# * *name*, the name of the bench +# * *common*, options to use on each case +# * NOALL, optional flag to avoid a last case including all additional options +# * *options*, sequences of options, one for each case +# +# Example: `bench_nitc_options "foo" "-a -b" -c "-d -e"` generates 4 cases: +# +# * only *common*: `nitc -a -b` +# * *common* and first *options*: `nitc -a -b -c` +# * *common* and second *options*: `nitc -a -b -d -e` +# * all: *common* and all *options*: `nitc -a -b -c -d -e` +function bench_nitc_options() { tag=$1 shift - name="$FUNCNAME-$tag" + common=$1 + shift + name="$FUNCNAME-$tag$common" + name=${name// /} skip_test "$name" && return - prepare_res "$name.dat" "no options" "nitg-g without options" - run_compiler "nitg-g" ./nitg --global + prepare_res "$name.dat" "no options" "nitc $common without more options" + run_compiler "nitc-$name" ./nitc $common if test "$1" = NOALL; then + withall= shift - elif test -n "$2"; then - prepare_res "$name-all.dat" "all" "nitg-g with all options $@" - run_compiler "nitg-g-$tag" ./nitg --global $@ + else + withall=true fi for opt in "$@"; do - ot=${opt// /+} - prepare_res "$name$ot.dat" "$opt" "nitg-g with option $opt" - run_compiler "nitg-g$ot" ./nitg --global $opt + ot=${opt// /} + prepare_res "$name$ot.dat" "$opt" "nitc with option $opt" + run_compiler "nitc-$name" ./nitc $common $opt done - plot "$name.gnu" -} -bench_nitg-g_options "slower" --hardening -bench_nitg-g_options "nocheck" --no-check-covariance --no-check-attr-isset --no-check-assert --no-check-autocast --no-check-other - -function bench_nitg-s_options() -{ - tag=$1 - shift - name="$FUNCNAME-$tag" - skip_test "$name" && return - prepare_res "$name.dat" "no options" "nitg-s without options" - run_compiler "nitg-s" ./nitg --separate - - if test "$1" = NOALL; then - shift - elif test -n "$2"; then - prepare_res "$name-all.dat" "all" "nitg-s with all options $@" - run_compiler "nitg-s-$tag" ./nitg --separate $@ + if test -n "$2" -a -n "$withall"; then + prepare_res "$name-all.dat" "all" "nitc with all options $@" + run_compiler "nitc-$name" ./nitc $common $@ fi - for opt in "$@"; do - ot=${opt// /+} - prepare_res "$name-$ot.dat" "$opt" "nitg-s with option $opt" - run_compiler "nitg-s$ot" ./nitg --separate $opt - done - plot "$name.gnu" } -bench_nitg-s_options "slower" --hardening --no-inline-intern --no-union-attribute --no-shortcut-equal --no-shortcut-range "--no-gcc-directive likely" "--no-gcc-directive noreturn" -bench_nitg-s_options "nocheck" --no-check-covariance --no-check-attr-isset --no-check-assert --no-check-autocast --no-check-other -bench_nitg-s_options "faster" --inline-coloring-numbers --inline-some-methods --direct-call-monomorph "--inline-some-methods --direct-call-monomorph" -bench_nitg-s_options "typing" NOALL --bm-typing --phand-typing -function bench_nitg-e_options() -{ - tag=$1 - shift - name="$FUNCNAME-$tag" - skip_test "$name" && return - prepare_res "$name.dat" "no options" "nitg-e without options" - run_compiler "nitg-e" ./nitg --erasure +bench_nitc_options "slower" --global --hardening --no-shortcut-range +bench_nitc_options "nocheck" --global --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert - if test "$1" = NOALL; then - shift - elif test -n "$2"; then - prepare_res "$name-all.dat" "all" "nitg-e with all options $@" - run_compiler "nitg-e-$tag" ./nitg --erasure $@ - fi +bench_nitc_options "slower" --separate --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern "--no-gcc-directive likely --no-gcc-directive noreturn" "--no-tag-primitives" "--colo-dead-methods" --type-poset +bench_nitc_options "nocheck" --separate --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert +bench_nitc_options "faster" --separate --skip-dead-methods --inline-coloring-numbers --inline-some-methods --direct-call-monomorph "--inline-some-methods --direct-call-monomorph" - for opt in "$@"; do - ot=${opt// /+} - prepare_res "$name$ot.dat" "$opt" "nitg-e with option $opt" - run_compiler "nitg-e$ot" ./nitg --erasure $opt - done +bench_nitc_options "slower" --erasure --hardening --no-shortcut-equal --no-union-attribute --no-shortcut-range --no-inline-intern +bench_nitc_options "nocheck" --erasure --no-check-null --no-check-autocast --no-check-attr-isset --no-check-covariance --no-check-assert --no-check-erasure-cast --no-check-all +bench_nitc_options "faster" --erasure --skip-dead-methods --inline-coloring-numbers --inline-some-methods --direct-call-monomorph --rta - plot "$name.gnu" -} -bench_nitg-e_options "slower" --hardening --no-inline-intern --no-union-attribute --no-shortcut-equal --no-shortcut-range -bench_nitg-e_options "nocheck" --no-check-covariance --no-check-attr-isset --no-check-assert --no-check-autocast --no-check-other --no-check-erasure-cast -bench_nitg-e_options "faster" --inline-coloring-numbers -bench_nitg-e_options "typing" NOALL --bm-typing # --phand-typing +bench_nitc_options "engine" "" NOALL "--separate" "--erasure" "--separate --semi-global" "--erasure --semi-global" "--erasure --semi-global --rta" "--global" +bench_nitc_options "policy" "" NOALL "--separate" "--erasure" "--separate --no-check-covariance" "--erasure --no-check-covariance --no-check-erasure-cast" +bench_nitc_options "nullables" "" "--no-check-attr-isset" "--no-union-attribute" +bench_nitc_options "linkboost" "" NOALL --trampoline-call --colors-are-symbols "--colors-are-symbols --trampoline-call" "--separate --link-boost" "--separate --colors-are-symbols --guard-call" "--separate --colors-are-symbols --direct-call-monomorph0" "--substitute-monomorph" +bench_nitc_options "monomorph" "" --direct-call-monomorph0 --direct-call-monomorph -function bench_engines() -{ - name="$FUNCNAME" - skip_test "$name" && return - prepare_res "$name-nitg-g.dat" "nitg-g" "nitg with --global" - run_compiler "nitg-g" ./nitg --global - prepare_res "$name-nitg-s.dat" "nitg-s" "nitg with --separate" - run_compiler "nitg-s" ./nitg --separate - prepare_res "$name-nitg-e.dat" "nitg-e" "nitg with --erasure" - run_compiler "nitg-e" ./nitg --erasure - plot "$name.gnu" -} -bench_engines +bench_nitc_options "misc" "" --log --typing-test-metrics --invocation-metrics --isset-checks-metrics --tables-metrics --no-stacktrace --release --debug #FIXME add --sloppy -function bench_nitg-e_gc() +function bench_nitc-e_gc() { name="$FUNCNAME" skip_test "$name" && return - prepare_res "$name-nitg-e-malloc.dat" "nitg-e-malloc" "nitg with --erasure and malloc" - NIT_GC_OPTION="malloc" run_compiler "nitg-e-malloc" ./nitg --erasure - prepare_res "$name-nitg-e.dat" "nitg-e" "nitg with --erasure" - run_compiler "nitg-e" ./nitg --erasure + prepare_res "$name-nitc-e.dat" "nitc-e" "nitc with --erasure" + run_compiler "nitc-e" ./nitc --erasure + prepare_res "$name-nitc-e-malloc.dat" "nitc-e-malloc" "nitc with --erasure and malloc" + NIT_GC_OPTION="malloc" run_compiler "nitc-e-malloc" ./nitc --erasure + prepare_res "$name-nitc-e-large.dat" "nitc-e-large" "nitc with --erasure and large" + NIT_GC_OPTION="large" run_compiler "nitc-e-large" ./nitc --erasure plot "$name.gnu" } -bench_nitg-e_gc +bench_nitc-e_gc -function bench_cc_nitg-e() +function bench_cc_nitc-e() { name="$FUNCNAME" skip_test "$name" && return 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 f=`echo "$o" | cut -f1 -d:` o=`echo "$o" | cut -f2 -d:` - prepare_res "$name-nitg-e-$f.dat" "nitg-e-$f" "nitg with --erasure --make-flags $o" - run_compiler "nitg-e-$f" ./nitg --erasure --make-flags "$o" + prepare_res "$name-nitc-e-$f.dat" "nitc-e-$f" "nitc with --erasure --make-flags $o" + run_compiler "nitc-e-$f" ./nitc --erasure --make-flags "$o" done plot "$name.gnu" } -bench_cc_nitg-e - -function bench_policy() -{ - name="$FUNCNAME" - skip_test "$name" && return - prepare_res "$name-nitg-s.dat" "nitg-s" "nitg with --separate" - run_compiler "nitg-s" ./nitg --separate - prepare_res "$name-nitg-e.dat" "nitg-e" "nitg with --erasure" - run_compiler "nitg-e" ./nitg --erasure - prepare_res "$name-nitg-su.dat" "nitg-su" "nitg with --separate --no-check-covariance" - run_compiler "nitg-su" ./nitg --separate --no-check-covariance - prepare_res "$name-nitg-eu.dat" "nitg-eu" "nitg with --erasure --no-check-covariance --no-check-erasure-cast" - run_compiler "nitg-eu" ./nitg --erasure --no-check-covariance --no-check-erasure-cast - plot "$name.gnu" -} -bench_policy +bench_cc_nitc-e function bench_compilation_time { name="$FUNCNAME" skip_test "$name" && return - prepare_res "$name-nitg-g.dat" "nitg-g" "nitg --global" - for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitg.nit; do - bench_command `basename "$i" .nit` "" ./nitg --global "$i" --no-cc + prepare_res "$name-nitc-g.dat" "nitc-g" "nitc --global" + for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitc.nit; do + bench_command `basename "$i" .nit` "" ./nitc --global "$i" --no-cc done - prepare_res "$name-nitg-s.dat" "nitg-s" "nitg --separate" - for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitg.nit; do - bench_command `basename "$i" .nit` "" ./nitg --separate "$i" --no-cc + prepare_res "$name-nitc-s.dat" "nitc-s" "nitc --separate" + for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitc.nit; do + bench_command `basename "$i" .nit` "" ./nitc --separate "$i" --no-cc done - prepare_res "$name-nitg-e.dat" "nitg-e" "nitg --erasure" - for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitg.nit; do - bench_command `basename "$i" .nit` "" ./nitg --erasure "$i" --no-cc + prepare_res "$name-nitc-e.dat" "nitc-e" "nitc --erasure" + for i in ../examples/hello_world.nit ../src/test_parser.nit ../src/nitc.nit; do + bench_command `basename "$i" .nit` "" ./nitc --erasure "$i" --no-cc done plot "$name.gnu" } bench_compilation_time -if test -n "$html"; then - echo >>"$html" "" -fi +echo >>"$html" "" + +echo >>"$xml" "" if test -n "$died"; then echo "Some commands failed"