tester and cas if n==2
This commit is contained in:
parent
e99b6f1ad4
commit
33ac159055
@ -92,6 +92,7 @@ void common_rotations(int *shortest_a, int *shortest_b, t_state *state)
|
||||
void sortmore(t_state *state)
|
||||
{
|
||||
push_all_but_3_b(state);
|
||||
if (ft_lstsize(state->a) == 3)
|
||||
sort3(state);
|
||||
while (state->b)
|
||||
b_merge_a(best_merge_a(state), state);
|
||||
|
||||
70
tester.sh
70
tester.sh
@ -1,30 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script is used to test the program
|
||||
# test case 1
|
||||
|
||||
echo "Test case 1"
|
||||
MAX=0
|
||||
MIN=10000
|
||||
for i in {1..100}
|
||||
do
|
||||
ARG=$(shuf -i 0-1000 -n 500)
|
||||
N=$(./push_swap $ARG | wc -l)
|
||||
if [ $N -gt $MAX ]
|
||||
run_test_case() {
|
||||
echo "Test case $1"
|
||||
MAX=0
|
||||
MIN=10000000
|
||||
AVG=0
|
||||
ITER=$2
|
||||
N=$1
|
||||
MAX_ARGS=""
|
||||
for i in $(seq 1 $ITER)
|
||||
do
|
||||
ARG=$(seq -1000 1000 | shuf -n $N)
|
||||
OPS=$(./push_swap $ARG | wc -l)
|
||||
OK=$(./push_swap $ARG | ./checker_linux $ARG)
|
||||
if [ $OPS -gt $MAX ]
|
||||
then
|
||||
if [ $N -gt 5500 ]; then
|
||||
echo "Max: $N | $(echo $ARG | tr -d '\n')"
|
||||
MAX_ARGS="Max: $OPS | $(echo $ARG | tr -d '\n')"
|
||||
MAX=$OPS
|
||||
fi
|
||||
MAX=$N
|
||||
fi
|
||||
if [ $N -lt $MIN ]
|
||||
if [ $OPS -lt $MIN ]
|
||||
then
|
||||
MIN=$N
|
||||
MIN=$OPS
|
||||
fi
|
||||
AVG=$((AVG + N))
|
||||
done
|
||||
AVG=$((AVG / 100))
|
||||
echo "Max: $MAX"
|
||||
echo "Min: $MIN"
|
||||
echo "Average: $AVG"
|
||||
AVG=$((AVG + OPS))
|
||||
if [ $OK != "OK" ]
|
||||
then
|
||||
echo "================================"
|
||||
echo "Error"
|
||||
echo "Args: $ARG"
|
||||
echo "Ops: $OPS"
|
||||
echo "Checker: $OK"
|
||||
echo "================================"
|
||||
return
|
||||
fi
|
||||
done
|
||||
AVG=$((AVG / ITER))
|
||||
echo "Iterations: $ITER"
|
||||
echo "Max: $MAX"
|
||||
echo "Min: $MIN"
|
||||
echo "Average: $AVG"
|
||||
echo "--------------------------------"
|
||||
echo "Max Args: $MAX_ARGS"
|
||||
echo "--------------------------------"
|
||||
echo ""
|
||||
|
||||
}
|
||||
|
||||
run_test_case 1 10
|
||||
run_test_case 2 10
|
||||
run_test_case 3 200
|
||||
run_test_case 5 200
|
||||
run_test_case 50 100
|
||||
run_test_case 100 100
|
||||
run_test_case 500 50
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user