run-benchmark.sh 2.35 KB
Newer Older
Etienne Renault's avatar
Etienne Renault committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# /bin/zsh
# This script runs the benchmark as presented in the paper

# Files from RERSchallenge, category "Sequential Reachability Problems"
# Note that we exclude from this benchmark all files that fall in the
# category "Sequential Reachability Problems/data structures, hard" since
# they require complex array manipulation that are not yet supported by
# the Go2Pins tool.
FILES="RERS/2016-Problem10.go \
       RERS/2016-Problem11.go \
       RERS/2016-Problem12.go \
       RERS/2016-Problem14.go \
       RERS/2016-Problem15.go \
       RERS/2017-Problem10.go \
       RERS/2017-Problem11.go \
       RERS/2017-Problem12.go \
       RERS/2017-Problem14.go \
       RERS/2017-Problem15.go \
       RERS/2018-Problem10.go \
       RERS/2018-Problem11.go \
       RERS/2019-Problem11.go \
       RERS/2019-Problem12.go \
       RERS/2019-Problem14.go \
       RERS/2019-Problem15.go "

OUTPUT=benchs.csv

echo "#filename,loc,transpile_time,compile_time,total_time,final_num_var,final_loc" > $OUTPUT

for model in $FILES; do
    echo "==> Processing $model"
    loc=$(wc -l $model| awk '{print $1}')
    echo "   - Line of code (original file):\t$loc"
    filename=$(basename -- "$model")
    filename="${filename%.*}"

    rers_inputs=$(cat $model | grep 'var inputs \[\]int'          | \
			 sed 's/var inputs \[\]int = \[\]int{//g' | \
			 sed 's/}//g' | sed 's/ *//g' | sed 's/,/;/g')

    start=$(date +%s.%N)
    ../go2pins -f -o $filename -rers "$rers_inputs" $model > /dev/null 2>&1
    end=$(date +%s.%N)
    transpile_time=$(python -c "print ('%.3f' %  (${end} - ${start}))")
    echo "   - Go2Pins processing:\t\t$transpile_time seconds"

    start=$(date +%s.%N)
    make -C $filename > /dev/null 2>&1
    end=$(date +%s.%N)
    compile_time=$(python -c "print ('%.3f' %  (${end} - ${start}))")
    echo "   - Compiling output:\t\t\t$compile_time seconds"

    total_time=`echo "$compile_time + $transpile_time"| bc`
    echo "   - Total Time:\t\t\t$total_time seconds"


    final_num_var=$($filename/main --displaylist | grep '\-' | wc -l)
    echo "   - Number of variables:\t\t$final_num_var"

    loc2=$(wc -l $filename/$filename.go| tail -n1|awk '{print $1}')
    echo "   - Line of code generated:\t\t$loc2"
    echo
    echo "$filename,$loc,$transpile_time,$compile_time,$total_time,$final_num_var,$loc2" >> benchs.csv
done

echo file : $OUTPUT contains the CSV of all previous values