bench: allow log directory to be placed elsewhere
[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 mcs-lock/mcs-lock spsc-queue/spsc-queue mpmc-queue/mpmc-1r2w mpmc-queue/mpmc-2r1w mpmc-queue/mpmc-queue linuxrwlocks/linuxrwlocks"
20 MODEL_ARGS="-f 4 -m 2"
21 COUNT=0
22
23 function run_test {
24         t=$1
25         shift
26         ARGS="$@"
27         RUN="./run.sh"
28         LOG=${DIR}/log-${COUNT}
29
30         echo "-----------------------------------------------"
31         echo "*******************************"
32         echo "Running test ${COUNT} (${t}): logging to ${LOG}"
33         echo "ARGS=${ARGS}"
34         echo "*******************************"
35         time ${RUN} ${t} ${ARGS} > ${LOG} 2>&1
36         echo
37         grep -A 2 "Number of executions" ${LOG} | tail -3
38         echo
39         echo "Test done; sleeping for a few seconds"
40         echo
41         sleep 3
42
43         echo "*******************************"
44         echo "Re-running test for timing data"
45         echo "*******************************"
46         (time ${RUN} ${t} ${ARGS} > /dev/null 2>&1) 2>&1
47         echo
48         echo "Test done; sleeping for a few seconds"
49         echo
50
51         let COUNT++
52 }
53
54 function run_all_tests {
55         echo ${DATE}
56
57         for t in ${TESTS}
58         do
59                 run_test ${t} ${MODEL_ARGS}
60         done
61         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 2 -w 1
62         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 1 -w 2
63         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 2 -w 2
64 }
65
66 mkdir ${DIR}
67 (git log --oneline -1; echo; run_all_tests) | tee ${DIR}/timing.log