bench.sh: don't 'grep' output
[model-checker-benchmarks.git] / bench.sh
1 #!/bin/bash
2
3 # A (work-in-progress) test script for running our benchmarks
4 # Runs all tests, logging output to a directory named
5 # '${BASEDIR}/run-<date-time>', where ${BASEDIR} is either the current
6 # directory or the first parameter to this script
7
8 ## Unfinished benchmarks - do not use
9 # queue williams-queue
10
11 DATECMD="date +%Y-%m-%d-%R"
12 DATE="`${DATECMD}`"
13 BASEDIR=.
14
15 [ $# -gt 0 ] && [ -d "$1" ] && BASEDIR="$1" && shift
16
17 DIR="${BASEDIR}/run-${DATE}"
18
19 TESTS="barrier/barrier"
20 TESTS+=" mcs-lock/mcs-lock"
21 TESTS+=" spsc-queue/spsc-queue"
22 TESTS+=" spsc-bugfix/spsc-queue"
23 TESTS+=" mpmc-queue/mpmc-2r1w"
24 TESTS+=" mpmc-queue/mpmc-1r2w-noinit"
25 TESTS+=" mpmc-queue/mpmc-queue-noinit"
26 TESTS+=" linuxrwlocks/linuxrwlocks"
27
28 MODEL_ARGS="-f 10 -m 2 -e 1"
29 COUNT=0
30
31 function run_test {
32         t=$1
33         shift
34         ARGS="$@"
35         RUN="./run.sh"
36         LOG=${DIR}/log-${COUNT}
37
38         echo "-----------------------------------------------"
39         echo "*******************************"
40         echo "Running test ${COUNT} (${t}): logging to ${LOG}"
41         echo "ARGS=${ARGS}"
42         echo "*******************************"
43         time ${RUN} ${t} ${ARGS} 2>&1 | tee ${LOG}
44         echo
45         echo "Test done; sleeping for a few seconds"
46         echo
47         sleep 3
48
49         echo "*******************************"
50         echo "Re-running test for timing data"
51         echo "*******************************"
52         (time ${RUN} ${t} ${ARGS} > /dev/null 2>&1) 2>&1
53         echo
54         echo "Test done; sleeping for a few seconds"
55         echo
56
57         let COUNT++
58 }
59
60 function run_all_tests {
61         echo ${DATE}
62
63         for t in ${TESTS}
64         do
65                 run_test ${t} ${MODEL_ARGS}
66         done
67         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 2 -w 1
68         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 1 -w 2
69         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 2 -w 2
70 }
71
72 mkdir ${DIR}
73 (git log --oneline -1; echo; run_all_tests) | tee ${DIR}/timing.log