Merge: Some improvement of benchmarks
authorJean Privat <jean@pryen.org>
Wed, 16 Sep 2015 17:11:54 +0000 (13:11 -0400)
committerJean Privat <jean@pryen.org>
Wed, 16 Sep 2015 17:11:54 +0000 (13:11 -0400)
Some work in the benchmarks directory. The most important stuff is some `make check` to test the brokenness of specific benches.

Pull-Request: #1723
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>

15 files changed:
benchmarks/.gitignore
benchmarks/Makefile [new file with mode: 0644]
benchmarks/bench_common.sh
benchmarks/bench_engines.sh
benchmarks/bench_languages.sh
benchmarks/bench_nitdoc.sh
benchmarks/bench_nitunit.sh
benchmarks/bench_plot.sh
benchmarks/markdown/Makefile
benchmarks/markdown/bench_markdown.sh
benchmarks/polygons/Makefile
benchmarks/polygons/nit/Makefile
benchmarks/polygons/nit/bench_polygon.sh
benchmarks/strings/Makefile
benchmarks/strings/bench_strings.sh

index 43fa343..b6bd96d 100644 (file)
@@ -7,3 +7,5 @@ index.html
 nitc
 nitdoc
 nitdoc.*
+logs
+nit_compile
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
new file mode 100644 (file)
index 0000000..6c62287
--- /dev/null
@@ -0,0 +1,5 @@
+all:
+       ./bench_engines.sh all
+
+check:
+       ./bench_engines.sh --fast --fast bench_nitc_options
index 4ea5ffe..207edd0 100644 (file)
@@ -94,3 +94,9 @@ function skip_test()
        return 1
 }
 
+# Helper function. Print the error message and set $died to 1
+function die()
+{
+       echo >&2 "error: $*"
+       died=1
+}
index b2534e7..37b2fb9 100755 (executable)
@@ -26,14 +26,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=2
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 # HELPER FOR NIT #
 
 # Run standards benchs on a compiler command
@@ -93,7 +85,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"
 }
 
@@ -105,11 +96,14 @@ while [ "$stop" = false ]; do
                -n) count="$2"; shift; shift;;
                --dry) dry_run=true; shift;;
                --fast) fast=true$fast; shift;;
-               --html) html="index.html"; echo >"$html" "<html><head></head><body>"; shift;;
+               --html) shift;; # Deprecated
                *) stop=true
        esac
 done
 
+html="index.html"
+echo >"$html" "<html><head></head><body>"
+
 xml="bench_engines.xml"
 echo "<testsuites><testsuite>" > "$xml"
 
@@ -195,12 +189,12 @@ function bench_nitc_options()
 
        for opt in "$@"; do
                ot=${opt// /}
-               prepare_res "$name$ot.dat" "$opt" "nitc-g with option $opt"
+               prepare_res "$name$ot.dat" "$opt" "nitc with option $opt"
                run_compiler "nitc-$name" ./nitc $common $opt
        done
 
        if test -n "$2" -a -n "$withall"; then
-               prepare_res "$name-all.dat" "all" "nitc-g with all options $@"
+               prepare_res "$name-all.dat" "all" "nitc with all options $@"
                run_compiler "nitc-$name" ./nitc $common $@
        fi
 
@@ -210,20 +204,22 @@ function bench_nitc_options()
 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
 
-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"
+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"
 
 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
+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
 
 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"
+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
 
+bench_nitc_options "misc" "" --log --typing-test-metrics --invocation-metrics --isset-checks-metrics --tables-metrics --no-stacktrace --release --debug #FIXME add --sloppy
+
 function bench_nitc-e_gc()
 {
        name="$FUNCNAME"
@@ -272,9 +268,7 @@ function bench_compilation_time
 }
 bench_compilation_time
 
-if test -n "$html"; then
-       echo >>"$html" "</body></html>"
-fi
+echo >>"$html" "</body></html>"
 
 echo >>"$xml" "</testsuite></testsuites>"
 
index 0e0b59a..2a33170 100755 (executable)
@@ -26,14 +26,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=2
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index 07613b2..4a1d2a7 100755 (executable)
@@ -24,14 +24,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=3
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index 53eb38c..23279f1 100755 (executable)
@@ -24,14 +24,6 @@ source ./bench_plot.sh
 # Can be overrided with 'the option -n'
 count=3
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index e874308..08a13e6 100755 (executable)
@@ -103,7 +103,8 @@ if test -n "$html"; then
        echo gnuplot -e "set term png; set output \"$bn.png\"" "$1"
 
        echo >>"$html" "<img src=\"$bn.png\"/>"
-else
+fi
+if test -n "$DISPLAY"; then
        echo "# gnuplot -p $1"
        gnuplot -p "$1"
 fi
index 802fab6..ca25141 100644 (file)
@@ -15,6 +15,9 @@
 all:
        ./bench_markdown.sh all
 
+check:
+       ./bench_markdown.sh -s 1 nit
+
 clean:
        $(MAKE) clean -C benches
        $(MAKE) clean -C engines
index aaa34f0..485b944 100755 (executable)
@@ -24,13 +24,8 @@ source ../bench_plot.sh
 # Can be overrided with 'the option -n'
 count=2
 
-### HELPER FUNCTIONS ##
-
-function die()
-{
-       echo >&2 "error: $*"
-       died=1
-}
+# Default number of times the input file is transformed during a single run
+s=200
 
 ## HANDLE OPTIONS ##
 
@@ -39,6 +34,7 @@ function usage()
        echo "run_bench: [options]* benchname"
        echo "  -v: verbose mode"
        echo "  -n count: number of execution for each bar (default: $count)"
+       echo "  -s size: number of transformations for each run (default: $s)"
        echo "  --dry: Do not run the commands, just reuse the data and generate the graph"
        echo "  -h: this help"
 }
@@ -49,6 +45,7 @@ while [ "$stop" = false ]; do
                -v) verbose=true; shift;;
                -h) usage; exit;;
                -n) count="$2"; shift; shift;;
+               -s) s="$2"; shift; shift;;
                --dry) dry_run=true; shift;;
                *) stop=true
        esac
@@ -73,8 +70,8 @@ outdir="./out"
 engdir="./engines"
 bncdir="./benches/out"
 mkdir -p $outdir
-
-s=200
+html="index.html"
+echo >"$html" "<html><head></head><body>"
 
 function bench_nitmd()
 {
@@ -140,6 +137,8 @@ if test "$#" -gt 0; then
     plot $outdir/bench_markdown.gnu
 fi
 
+echo >>"$html" "</body></html>"
+
 if test -n "$died"; then
        echo "Some commands failed"
        exit 1
index e6bd303..f7d0763 100644 (file)
@@ -1,3 +1,6 @@
 all:
        $(MAKE) all -C nit
        $(MAKE) all -C java
+
+check:
+       $(MAKE) check -C nit
index e327368..71dffea 100644 (file)
@@ -17,3 +17,11 @@ convexity_b:
 
 contain_b:
        ./bench_polygon.sh contain
+
+check:
+       ./bench_polygon.sh -p 100 add_vertex
+       ./bench_polygon.sh -p 100 sort_vertices
+       ./bench_polygon.sh -p 100 intersection
+       ./bench_polygon.sh -p 100 convex_hull
+       ./bench_polygon.sh -p 100 convexity
+       ./bench_polygon.sh -p 100 contain
index 52895e9..8b7fc08 100755 (executable)
@@ -166,3 +166,9 @@ case "$1" in
        contain) shift; bench_contain $@;;
        *) usage; exit;;
 esac
+
+if test -n "$died"; then
+       echo "Some commands failed"
+       exit 1
+fi
+exit 0
index 3717681..2453d1b 100644 (file)
@@ -12,6 +12,8 @@ iter:
 index:
        ./bench_strings.sh index 10000000 50 25 200
 
+check: basic
+
 basic:
        ./bench_strings.sh basic
 
index 7a09065..5d24653 100755 (executable)
@@ -205,14 +205,14 @@ function launch_bench()
        echo "  Trying variant $variant for benchmark $bench"
        echo "---------------------------------------------------------"
        git diff-index --quiet HEAD || {
-               echo "Cannot run benches on a dirty working directory."
-               echo "Please commit or stash your modifications and relaunch the command."
-               exit 1
+               die "Cannot run benches on a dirty working directory."
+               die "Please commit or stash your modifications and relaunch the command."
+               return
        }
        git am $curr_rev || {
-               echo "Error when applying patch $curr_rev"
-               git am --abort;
-               exit 1;
+               die "Error when applying patch $curr_rev"
+               git am --abort
+               return
        }
        if [ "$need_bootstrap" = true ]; then
                prepare_compiler
@@ -263,12 +263,6 @@ function main()
        bench=$1
        shift;
 
-       git diff-index --quiet HEAD || {
-               echo "Cannot run benches on a dirty working directory."
-               echo "Please commit or stash your modifications and relaunch the command."
-               exit 1
-       }
-
        head=`git rev-parse HEAD`
        variant="HEAD"
        need_plot=true
@@ -314,3 +308,9 @@ function main()
 }
 
 main "$@";
+
+if test -n "$died"; then
+       echo "Some commands failed"
+       exit 1
+fi
+exit 0