Merge branch 'bench'
[nit.git] / benchmarks / bench_engines.sh
index f5385c0..df4bba2 100755 (executable)
@@ -96,6 +96,9 @@ function skip_test()
        else
                return 0
        fi
+       if test -n "$html"; then
+               echo >>"$html" "<h2>$1</h2>"
+       fi
        echo "*"
        echo "* $1 *****"
        echo "*"
@@ -146,6 +149,7 @@ 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"
 }
 
@@ -157,6 +161,7 @@ while [ "$stop" = false ]; do
                -n) count="$2"; shift; shift;;
                --dry) dry_run=true; shift;;
                --fast) fast=true; shift;;
+               --html) html="index.html"; echo >"$html" "<html><head></head><body>"; shift;;
                *) stop=true
        esac
 done
@@ -214,6 +219,12 @@ function bench_steps()
        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
@@ -234,7 +245,9 @@ function bench_nitg-g_options()
        prepare_res "$name.dat" "no options" "nitg-g without options"
        run_compiler "nitg-g" ./nitg --global
 
-       if test -n "$2"; then
+       if test "$1" = NOALL; then
+               shift
+       elif test -n "$2"; then
                prepare_res "$name-all.dat" "all" "nitg-g with all options $@"
                run_compiler "nitg-g-$tag" ./nitg --global $@
        fi
@@ -258,7 +271,9 @@ function bench_nitg-s_options()
        prepare_res "$name.dat" "no options" "nitg-s without options"
        run_compiler "nitg-s" ./nitg --separate
 
-       if test -n "$2"; then
+       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 $@
        fi
@@ -273,7 +288,7 @@ function bench_nitg-s_options()
 bench_nitg-s_options "slower" --hardening --no-inline-intern --no-union-attribute --no-shortcut-equal --no-shortcut-range
 bench_nitg-s_options "nocheck" --no-check-covariance --no-check-initialization --no-check-assert --no-check-autocast --no-check-other
 bench_nitg-s_options "faster" --inline-coloring-numbers
-bench_nitg-s_options "typing" --bm-typing --phand-typing
+bench_nitg-s_options "typing" NOALL --bm-typing --phand-typing
 
 function bench_nitg-e_options()
 {
@@ -284,7 +299,9 @@ function bench_nitg-e_options()
        prepare_res "$name.dat" "no options" "nitg-e without options"
        run_compiler "nitg-e" ./nitg --erasure
 
-       if test -n "$2"; then
+       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
@@ -299,7 +316,7 @@ function bench_nitg-e_options()
 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-initialization --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" --bm-typing --phand-typing
+bench_nitg-e_options "typing" NOALL --bm-typing # --phand-typing
 
 function bench_nitc_gc()
 {
@@ -420,6 +437,10 @@ function bench_compilation_time
        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
        done
+       prepare_res "$name-nitg-e.dat" "nitg-e" "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
+       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
@@ -428,6 +449,10 @@ function bench_compilation_time
 }
 bench_compilation_time
 
+if test -n "$html"; then
+       echo >>"$html" "</body></html>"
+fi
+
 if test -n "$died"; then
        echo "Some commands failed"
        exit 1