Adding new benchmarks for Sudoku + scripts for processing and gathering the results
[Benchmarks_CSolver.git] / sudoku-csolver / bench.sh
1 #!/bin/bash
2
3 #Terminate the script if even one command fails
4 #set -e
5
6
7 #Variables
8 source ../common.sh
9 PROBLEMS=./testcase/*.problem
10
11 #Checking the number of 
12 if [ "$#" -lt 1 ]; then
13         echo "Illegal number of argument"
14         echo "./bench.sh [NUMBER] [--csolver/--dump]"
15         exit 1
16 fi
17
18 rm -f *.csv
19
20 for PAR in $PROBLEMS; do
21         rm -f $TEMP
22         for ((i=0; i<"$1"; i++)); do
23                 echo "begin iteration: $i" >>$TEMP
24                 if [ "$#" -eq 1 ]; then
25                         START=$(date +%s.%N)
26                         timeout $TIMEMAX ./run.sh python Sudoku.py --file $PAR >> $TEMP
27                         END=$(date +%s.%N)
28                         DIFF=$(echo "$END - $START" | bc)
29                         echo "DONE!" >> $TEMP
30                         echo "Program Execution Time: $DIFF" >>$TEMP
31                 else
32                         if [ $2 = '--dump' ]; then
33                                 START=$(date +%s.%N)
34                                 timeout $TIMEMAX ./run.sh python Sudoku.py --file $PAR --dump >> $TEMP
35                                 END=$(date +%s.%N)
36                                 DIFF=$(echo "$END - $START" | bc)
37                                 echo "DONE!" >> $TEMP
38                                 echo "Program Execution Time: $DIFF" >>$TEMP
39                                 mkdir -p $DUMPDIR
40                                 mv DUMP* $DUMPDIR
41                         elif [ $2 = '--csolver' ]; then
42                                 START=$(date +%s.%N)
43                                 timeout $TIMEMAX ./run.sh python Sudoku.py --file $PAR --csolver >> $TEMP
44                                 END=$(date +%s.%N)
45                                 DIFF=$(echo "$END - $START" | bc)
46                                 echo "DONE!" >> $TEMP
47                                 echo "Program Execution Time: $DIFF" >>$TEMP
48                         else
49                                 echo "Unknown command : " $2
50                                 exit 1
51                         fi
52                 fi
53         done
54         ./parse.sh $TEMP $PAR
55 done
56