-
Notifications
You must be signed in to change notification settings - Fork 3
/
benchmark.sh
46 lines (42 loc) · 1.44 KB
/
benchmark.sh
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
# **************************************************************************** #
# #
# ::: :::::::: #
# benchmark.sh :+: :+: :+: #
# +:+ +:+ +:+ #
# By: vbrazhni <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/08/29 17:15:18 by vbrazhni #+# #+# #
# Updated: 2018/08/29 17:15:19 by vbrazhni ### ########.fr #
# #
# **************************************************************************** #
#!/bin/bash
MAX=0
ITERATIONS=0
LIMIT=700
FILE=problem_100
SUM=0
for i in {1..1000}
do
export ARG=`ruby -e "puts (1..100).to_a.shuffle.join(' ')"`
if ./push_swap $ARG | ./checker $ARG | grep -q KO
then
echo "Error!"
echo $ARG
break
fi
NUMBER="$(./push_swap $ARG | wc -l | sed 's/ //g')"
if [ "$NUMBER" -gt "$LIMIT" ]
then
echo $NUMBER >> $FILE
echo $ARG >> $FILE
fi
if [ "$NUMBER" -gt "$MAX" ]
then
MAX=$NUMBER;
fi
echo $i ":" $NUMBER
let SUM+=$NUMBER;
let ITERATIONS+=1
done
echo "AVG: $(($SUM / $ITERATIONS))"
echo "MAX: " $MAX