linuxrwlocks: add linux locks test
[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 'run-<date-time>'
5
6 ## Unfinished benchmarks - do not use
7 # queue williams-queue
8
9 DATECMD="date +%Y-%m-%d-%R"
10 DATE="`${DATECMD}`"
11 DIR="run-${DATE}"
12
13 TESTS="barrier/barrier mcs-lock/mcs-lock spsc-queue/spsc-queue mpmc-queue/mpmc-1r2w mpmc-queue/mpmc-2r1w mpmc-queue/mpmc-queue"
14 MODEL_ARGS="-f 4 -m 2"
15 COUNT=0
16
17 function run_test {
18         t=$1
19         shift
20         ARGS="$@"
21         RUN="./run.sh"
22         LOG=${DIR}/log-${COUNT}
23
24         echo "-----------------------------------------------"
25         echo "*******************************"
26         echo "Running test ${COUNT} (${t}): logging to ${LOG}"
27         echo "ARGS=${ARGS}"
28         echo "*******************************"
29         time ${RUN} ${t} ${ARGS} > ${LOG} 2>&1
30         echo
31         grep -A 2 "Number of executions" ${LOG} | tail -3
32         echo
33         echo "Test done; sleeping for a few seconds"
34         echo
35         sleep 3
36
37         echo "*******************************"
38         echo "Re-running test for timing data"
39         echo "*******************************"
40         time ${RUN} ${t} ${ARGS} > /dev/null 2>&1
41         echo
42         echo "Test done; sleeping for a few seconds"
43         echo
44
45         let COUNT++
46 }
47
48 function run_all_tests {
49         echo ${DATE}
50
51         for t in ${TESTS}
52         do
53                 run_test ${t} ${MODEL_ARGS}
54         done
55         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 2 -w 1
56         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 1 -w 2
57         #run_test mpmc-queue/mpmc-queue ${MODEL_ARGS} -- -r 2 -w 2
58 }
59
60 mkdir ${DIR}
61 (git log --oneline -1; echo; run_all_tests) | tee ${DIR}/timing.log