run_benchmarks.sh 1.19 KB
Newer Older
Philipp Meyer's avatar
Philipp Meyer committed
1
2
#!/usr/bin/bash

Philipp Meyer's avatar
Philipp Meyer committed
3
benchmarks=( "Lamport" "Dekker" "Szymanski" "Snapshot" "LeaderElectionDKR82" "Peterson" )
4
suffix=""
Philipp Meyer's avatar
Philipp Meyer committed
5
6
7
8
9
10
11

#2 hours
time_soft=$(expr 2 \* 3600)
time_hard=$(expr $time_soft + 60)
#6 gigabyte
mem_soft=$(expr 6 \* 1024 \* 1024)
mem_hard=$(expr $mem_soft + 1024)
Philipp Meyer's avatar
Philipp Meyer committed
12

13
14
15
for benchmark in ${benchmarks[@]}; do
    echo "Runnng benchmark $benchmark"
    bf="${benchmark}/benchmark${suffix}.out"
Philipp Meyer's avatar
Philipp Meyer committed
16
    echo "n user system elapsed memory" >$bf
17

Philipp Meyer's avatar
Philipp Meyer committed
18
19
20
21
22
    if [[ $benchmark == "Dekker" || $benchmark == "Szymanski" ]]; then
        nmax=2
    else
        nmax=5
    fi
23

Philipp Meyer's avatar
Philipp Meyer committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    for n in $(seq 2 $nmax); do
        file="${benchmark}/n${n}${suffix}.pnet"
        echo "Testing net $file"
        echo -n "$n " >>$bf
        output=$file-$n.out
        (
            ulimit -S -t $time_soft
            ulimit -H -t $time_hard
            ulimit -S -v $mem_soft
            ulimit -H -v $mem_hard
            /usr/bin/time -f "%U %S %e %M" -a -o $bf slapnet -vi --auto $file > ${file}${suffix}.out
        )
        result=$?
        if [[ result -eq 0 ]]; then
            echo 'Positive result'
        elif [[ result -eq 1 ]]; then
            echo 'Negative result'
        else
            echo 'Error'
        fi
Philipp Meyer's avatar
Philipp Meyer committed
44
    done
45
    echo
Philipp Meyer's avatar
Philipp Meyer committed
46
done