benches: introduces bench_markdown script
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 20 Jan 2015 23:31:51 +0000 (00:31 +0100)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 20 Jan 2015 23:31:51 +0000 (00:31 +0100)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

benchmarks/markdown/bench_markdown.sh [new file with mode: 0755]

diff --git a/benchmarks/markdown/bench_markdown.sh b/benchmarks/markdown/bench_markdown.sh
new file mode 100755 (executable)
index 0000000..639ffdd
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/bash
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Shell script to bench nitmd over different kind of document.
+
+source ../bench_common.sh
+source ../bench_plot.sh
+
+## CONFIGURATION OPTIONS ##
+
+# Default number of times a command must be run with bench_command
+# Can be overrided with 'the option -n'
+count=2
+
+### HELPER FUNCTIONS ##
+
+function die()
+{
+       echo >&2 "error: $*"
+       died=1
+}
+
+## HANDLE OPTIONS ##
+
+function usage()
+{
+       echo "run_bench: [options]* benchname"
+       echo "  -v: verbose mode"
+       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 "  -h: this help"
+}
+
+stop=false
+while [ "$stop" = false ]; do
+       case "$1" in
+               -v) verbose=true; shift;;
+               -h) usage; exit;;
+               -n) count="$2"; shift; shift;;
+               --dry) dry_run=true; shift;;
+               *) stop=true
+       esac
+done
+
+## GEN BENCHES
+cd benches; make; cd ..
+
+## COMPILE ENGINES
+cd engines; make; cd ..
+
+NOTSKIPED="$*"
+
+if test -z "$NOTSKIPED"; then
+       usage
+       echo "List of available benches:"
+       echo "* all: run all the benches"
+fi
+
+## EFFECTIVE BENCHS ##
+outdir="./out"
+engdir="./engines"
+bncdir="./benches/out"
+mkdir -p $outdir
+
+s=50
+
+if test "$#" -gt 0; then
+    plot $outdir/bench_markdown.gnu
+fi
+
+if test -n "$died"; then
+       echo "Some commands failed"
+       exit 1
+fi
+exit 0