#!/usr/bin/env sh
LOGDIR=logs
COMMON="-X 5 -Y 5 -N 10000"
SCRIPTPATH=$(dirname $0)

# compile the platform
make
if [[ ! -f simul.x ]]; then exit 1; fi;

mkdir -p $LOGDIR
#for (( x = 0; x < 5; x++ )); do
#	for (( y = 0; y < 5; y++ )); do
#		for (( load = 100; load <= 1000; load += 100 )); do
#			if [[ ( $x == $FX ) && ( $y == $FY ) ]]; then continue; fi
#			LOGFILE=$LOGDIR/$(echo latency'_'$x'_'$y'_'$load);
#			ARGS="$COMMON -SX $x -SY $y -FX $FX -FY $FY -L $load";
#			echo "./simul.x $ARGS ($LOGFILE)"
#			./simul.x $ARGS > $LOGFILE 2>/dev/null;
#			./broadcast_latency.sh $LOGFILE
#			if [[ $? == 1 ]]; then
#				echo "FAILURE";
#				exit 1;
#			fi
#		done
#	done
#done
for (( load = 25; load <= 550; load += 25 )); do
	LOGFILE=$LOGDIR/$(echo latency_all'_'$load);
	ARGS="$COMMON -L $load";
	echo "./simul.x $ARGS ($LOGFILE)"
	./simul.x $ARGS > $LOGFILE 2>/dev/null;
	$SCRIPTPATH/broadcast_latency.sh $LOGFILE
done;

for (( x = 0; x < 5; x++ )); do
	for (( y = 0; y < 5; y++ )); do
		for (( load = 25; load <= 550; load += 25 )); do
			LOGFILE=$LOGDIR/$(echo latency_all'_'$x'_'$y'_'$load);
			ARGS="$COMMON -FX $x -FY $y -L $load";
			echo "./simul.x $ARGS ($LOGFILE)"
			./simul.x $ARGS > $LOGFILE 2>/dev/null;
			$SCRIPTPATH/broadcast_latency.sh $LOGFILE
		done;
	done;
done;
