From ae2476ed592765c42a2895ff227e0f52e033a28c Mon Sep 17 00:00:00 2001 From: Marco Poletti Date: Sat, 28 Feb 2015 19:33:43 +0000 Subject: [PATCH] Add a run_benchs.sh script to automate running tests. --- .gitignore | 1 + run_benchs.sh | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100755 run_benchs.sh diff --git a/.gitignore b/.gitignore index c855b65c..f32e7ecc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ .kdev4/ /coverage +bench_results diff --git a/run_benchs.sh b/run_benchs.sh new file mode 100755 index 00000000..78e2ad90 --- /dev/null +++ b/run_benchs.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +set -e +set -o pipefail + +prefix_with() ( + local PREFIX=("$@") + while read line + do + echo "${PREFIX[@]}" "$line" + done +) + +progress() ( + local EXPECTED_LINES=$1 + local I=0 + echo "0/$EXPECTED_LINES (0%)" >&2 + while read line + do + echo "$line" + I="$[$I + 1]" + echo "$I/$EXPECTED_LINES ($[100 * $I / $EXPECTED_LINES]%)" >&2 + done +) + +print_stats() ( + local TOTAL=0 + local N=0 + for VALUE in "$@" + do + TOTAL="$(echo $TOTAL + $VALUE | bc -l)" + N="$[$N + 1]" + done + if [[ $N == 0 ]] + then + echo "N/A ()" + else + echo "$(echo $TOTAL / $N | bc -l) ($@)" + fi +) + +BASEDIR="$PWD" +COMPILERS=(g++ clang++) +# NUM_ITERATIONS = ITERATIONS_FACTOR/NUM_BINDINGS +ITERATIONS_FACTOR="$[400 * 1000 * 1000]" +# Must be multiples of 10 +NUM_BINDINGS_FOR_RUNTIME_TESTS=(100 1000) +# Must be multiples of 5 +NUM_BINDINGS_FOR_COMPILE_TESTS=(20 80 320) +NUM_LINES="$[${#COMPILERS[@]} * (${#NUM_BINDINGS_FOR_RUNTIME_TESTS[@]} * 3 + ${#NUM_BINDINGS_FOR_COMPILE_TESTS[@]})]" + +# All result lines are of the form: +# (