Skip to content

Commit

Permalink
Update benchmark script
Browse files Browse the repository at this point in the history
  • Loading branch information
shilangyu committed Dec 4, 2023
1 parent d0b362f commit 6b9a59e
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ set -e

BUILD_TYPE=Release ./build.sh &> /dev/null

MESSAGES=20
PROCESSES=128
AGREEMENT_COUNT=10
PROPOSE_AMOUNT=3
MAX_UNIQUE_PROPOSED=5
MAX_PROPOSED_VALUE=2147483648
PROCESSES=10
RUN_FOLDER=$(mktemp -d)
HOSTS_FILE=$RUN_FOLDER/hosts
OUTPUTS=$RUN_FOLDER/outputs
CONFIG_FILE=$RUN_FOLDER/fifo-broadcast.config
SLEEP_TIME_S=10
CONFIG_FILE=$RUN_FOLDER/lattice-agreement.config
SLEEP_TIME_S=30

mkdir $OUTPUTS

Expand All @@ -24,15 +27,36 @@ do
echo $i" localhost "$((11000 + $i)) >> $HOSTS_FILE
done

# create config file
echo $MESSAGES > $CONFIG_FILE
# pick random values
NUMS=()
for i in $(seq 1 $MAX_UNIQUE_PROPOSED)
do
num=$(shuf -i 1-$MAX_PROPOSED_VALUE -n 1)
NUMS+=($num)
done

# create config files
for i in $(seq 1 $PROCESSES)
do
echo $AGREEMENT_COUNT" "$PROPOSE_AMOUNT" "$MAX_UNIQUE_PROPOSED > $CONFIG_FILE.$i

for j in $(seq 1 $AGREEMENT_COUNT)
do
NUM=()
for k in $(shuf -i 0-$(($MAX_UNIQUE_PROPOSED-1)) -n $(shuf -i 1-$PROPOSE_AMOUNT -n 1))
do
NUM+=(${NUMS[$k]})
done

echo ${NUM[@]} >> $CONFIG_FILE.$i
done
done

# start all processes
PIDS=()
for i in $(seq 1 $PROCESSES)
do
./bin/da_proc --id $i --hosts $HOSTS_FILE --output $OUTPUTS/$i.out $CONFIG_FILE 1> $OUTPUTS/$i.stdout 2> $OUTPUTS/$i.stderr &
./bin/da_proc --id $i --hosts $HOSTS_FILE --output $OUTPUTS/$i.out $CONFIG_FILE.$i 1> $OUTPUTS/$i.stdout 2> $OUTPUTS/$i.stderr &
PIDS+=($!)
done

Expand All @@ -48,8 +72,8 @@ do
wait $pid || echo "Process "$(($key + 1))" exited with "$?
done

delivered=$(cat $OUTPUTS/*.out | grep '^d' | wc -l | xargs)
total=$(($PROCESSES * $PROCESSES * $MESSAGES))
delivered=$(cat $OUTPUTS/*.out | wc -l | xargs)
total=$(($PROCESSES * $AGREEMENT_COUNT))
frac=$(echo "$delivered/$total * 100" | bc -l)

echo "Delivered "$frac"%"

0 comments on commit 6b9a59e

Please sign in to comment.