Skip to content
Snippets Groups Projects
Commit 8722e9ef authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

muda os testes

parent 906c4423
No related branches found
No related tags found
No related merge requests found
Pipeline #
#!/bin/bash
# tempo máximo para executar, em milisegundos
tempo_max=10000 #10s
tempo_max=120000 #120s
# tamanhos do tabuleiro
tams=(16 32 64 128)
tams=(3 4 8 16 32 64 100)
# lista de cores
cores=(4 8 10 16)
cores=(4 8 10)
#-- Cores do terminal
RED='\033[0;31m'
......@@ -31,19 +31,33 @@ do
echo "Número de cores: ${cor}"
T_soma_cor=0
T_max_cor=0
for j in $(seq 1 $i)
N_TESTES=500
for j in $(seq 1 ${N_TESTES})
do
echo -ne "Tabuleiro com ${i} linhas e ${cor} cores: ${i}x${j} (T max: $(($T_max_cor/1000000000))."
printf "%03d" $(($T_max_cor/1000000))
echo -ne "Tabuleiro ${i}x${i} com ${cor} cores: (${j}/${N_TESTES}) (T max: $(($T_max_cor/1000000000))."
printf "%03d" $(($T_max_cor/1000000%1000))
echo -ne ")"\\r
semente=$RANDOM
# echo "Usando semente: ${semente}"
./test $i $j $cor $semente
./test $i $i $cor $semente
T_inicial=$(date +%s%N)
../main < "/tmp/${semente}.in" > /dev/null
../main < "/tmp/${semente}.in" > /tmp/resp.out
T_gasto=$(($(date +%s%N) - $T_inicial))
T_soma_cor=$(($T_gasto + $T_soma_cor))
T_soma_total=$(($T_gasto + $T_soma_total))
./floodit_h1 < "/tmp/${semente}.in" > /tmp/h1.out
./floodit_h2 < "/tmp/${semente}.in" > /tmp/h2.out
RESP=$(cat /tmp/resp.out | head -n1)
H1=$(cat /tmp/h1.out | tail -n2 | head -n1)
H2=$(cat /tmp/h2.out | tail -n2 | head -n1)
if [ $RESP -gt $H1 ]; then
echo -ne "${RED}Heurística h1 fez tabuleiro ${i} ${i} ${cor} ${semente} em ${H1} e nós em ${RESP}${NC}\n"
echo "${i} ${i} ${cor} ${semente} (h1: ${H1})" >> tabuleiros.txt
fi
if [ $RESP -gt $H2 ]; then
echo -ne "${RED}Heurística h2 fez tabuleiro ${i} ${i} ${cor} ${semente} em ${H2} e nós em ${RESP}${NC}\n"
echo "${i} ${i} ${cor} ${semente} (h2: ${H2})" >> tabuleiros.txt
fi
# tempo em segundos
S=$(($T_gasto/1000000000))
# tempo em milisegundos
......@@ -52,36 +66,38 @@ do
if [ $T_max_cor -lt $T_gasto ]; then
T_max_cor=$T_gasto
fi
if (($M>$tempo_max)); then
echo -e "\n${RED}Tabuleiro ${i} ${j} ${cor} ${semente} levou mais de ${tempo_max} milisegundos: ${S}.${M}s${NC}"
echo "${i} ${j} ${cor} ${semente}" >> tabuleiros.txt
fi
# if (($M>$tempo_max)); then
# echo -e "\n${RED}Tabuleiro ${i} ${i} ${cor} ${semente} levou mais de ${tempo_max} milisegundos: ${S}.${M}s${NC}"
# echo "${i} ${i} ${cor} ${semente}" >> tabuleiros.txt
# fi
rm "/tmp/${semente}.in"
rm "/tmp/resp.out"
rm "/tmp/h1.out"
rm "/tmp/h2.out"
done
T_medio_cor=$(($T_soma_cor/$i))
T_medio_cor=$(($T_soma_cor/${N_TESTES}))
S_medio_cor=$(($T_medio_cor/1000000000))
M_medio_cor=$(($T_medio_cor/1000000))
echo -ne "\n${CYAN}Tempo médio com ${cor} cores: ${S_medio_cor}."
printf "%03d" ${M_medio_cor}
printf "%03d" $((${M_medio_cor}%1000))
echo -e "s (${T_medio_cor})${NC}\n"
echo -e "${i}\t${cor}\t${M_medio_cor}" >> tempos.txt
echo -e "${i}\t${cor}\t$(($T_max_cor/1000000))" >> piores.txt
done
T_medio_total=$(( $T_soma_total/($i * ${#cores[*]}) ))
T_medio_total=$(( $T_soma_total/(${N_TESTES} * ${#cores[*]}) ))
S_medio_total=$(($T_medio_total/1000000000))
M_medio_total=$(($T_medio_total/1000000))
echo -ne "${BLUE}Tempo médio com tamanho ${i}: ${S_medio_total}."
printf "%03d" ${M_medio_total}
printf "%03d" $((${M_medio_total}%1000))
echo -e "s (${T_medio_total})${NC}\n"
echo -e "${i}\t${M_medio_total}" >> medias.txt
done
fs=$(cat tabuleiros.txt | wc -l)
if [ ${fs} -gt "1" ]; then
echo -e "${RED}${fs} tabuleiro(s) passou(passaram) do tempo limite de ${tempo_max} milisegundos:${NC}"
echo -e "${RED}${fs} tabuleiro(s) perdeu(perderam) para outras heurísticas${NC}"
cat tabuleiros.txt
exit 1
else
echo -e "${GREEN}Nenhum tabuleiro passou do tempo limite de ${tempo_max} milisegundos${NC}"
exit 0
echo -e "${GREEN}Nenhum tabuleiro perdeu para as outras heurísticas${NC}"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment