-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_sudoku_diabolical_tests
38 lines (38 loc) · 1.22 KB
/
run_sudoku_diabolical_tests
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
#!/usr/bin/bash
#check for n_sudokus argument
if [[ $# -lt 1 || $# -gt 1 ]] ; then
echo 'Wrong arguments provided'
exit 1
fi
declare -a diabolical_sudoku_puzzles
input="./ressources/diabolical.txt"
n_sudokus=$1
n=0
#some diabolical puzzles (n_sudokus) to test from the file
while IFS= read -r line
do
hash=$(echo "$line" | awk '{print $1}')
diabolical_sudoku_puzzles[${#diabolical_sudoku_puzzles[@]}]="$hash"
((n++))
if [[ n -eq n_sudokus ]]; then
break;
fi
done < "$input"
#make compile main sudoku solving C program
make clean && make
#set variables
stats_file="./benchmark/diabolical/stats-$$.txt"
n=0
#try the diabolical puzzles
for i in "${diabolical_sudoku_puzzles[@]}"
do
result=$(./bin/main "diabolical.txt" "$i")
echo -e "$result"
#get the execution time for the x axis and the final cost of the algorithm for the y axis
exec_time=$(echo "$result" | grep ">> CPU Execution time of the sudoku solving simulation :" | awk 'NF>1{print $NF}')
end_cost=$(echo "$result" | grep ">> Best solution (lowest cost) found during the execution of the simulation :" | awk 'NF>1{print $NF}')
echo "$exec_time $end_cost" >> "$stats_file"
done
#create benchmark graph
./bin/benchmark "6" "$stats_file"
#rm -r "fit.log"