Skip to content

Commit fded613

Browse files
committed
fix: linting and apply review comments
1 parent c001b96 commit fded613

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

mithril-test-lab/benchmark/aggregator-prover/benchmark-aggregator-prover.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fi
2525
if [ -z "${TRANSACTIONS_PER_REQUEST_MAX}" ]; then
2626
TRANSACTIONS_PER_REQUEST_MAX=100
2727
fi
28-
TRANSACTIONS=$(cat $TRANSACTIONS_FILE | tr "\n" " ")
29-
TRANSACTIONS_AVAILABLE=$(echo $TRANSACTIONS | wc -w)
28+
TRANSACTIONS=$(tr "\n" " " < "$TRANSACTIONS_FILE")
29+
TRANSACTIONS_AVAILABLE=$(echo "$TRANSACTIONS" | wc -w | xargs)
3030
TRANSACTIONS_PER_REQUEST_MAX=$(( TRANSACTIONS_AVAILABLE < TRANSACTIONS_PER_REQUEST_MAX ? TRANSACTIONS_AVAILABLE : TRANSACTIONS_PER_REQUEST_MAX ))
3131

3232
if [ -z "${TRANSACTIONS_PER_REQUEST_STEP}" ]; then
@@ -58,7 +58,7 @@ if [ -z "${OUT_FILE}" ]; then
5858
rm -f $OUT_FILE
5959
echo "Using the default OUT_FILE: $OUT_FILE"
6060
fi
61-
mkdir -p $(dirname "$OUT_FILE")
61+
mkdir -p "$(dirname "$OUT_FILE")"
6262

6363
# Run stress test
6464
RUN_STRESS_TEST() {
@@ -75,14 +75,14 @@ RUN_STRESS_TEST() {
7575
TRANSACTIONS_FILE=$8
7676
TMP_FILE="test.tmp"
7777
echo ">> [#$INDEX_RUN/$TOTAL_RUN] Running stress test with $AB_TOTAL_REQUESTS requests with $TRANSACTIONS_PER_REQUEST transactions per request and $AB_CONCURRENCY concurrency"
78-
TRANSACTIONS_LIST=$(head -n $TRANSACTIONS_PER_REQUEST $TRANSACTIONS_FILE | tr "\n" ",")
78+
TRANSACTIONS_LIST=$(head -n $TRANSACTIONS_PER_REQUEST "$TRANSACTIONS_FILE" | tr "\n" ",")
7979
AGGREGATOR_PROVER_URL="$AGGREGATOR_ENDPOINT/proof/cardano-transaction?transaction_hashes=$TRANSACTIONS_LIST"
80-
if $(ab -n $AB_TOTAL_REQUESTS -c $AB_CONCURRENCY -s $AB_TIMEOUT $AGGREGATOR_PROVER_URL > $TMP_FILE) ; then
80+
if ab -n $AB_TOTAL_REQUESTS -c $AB_CONCURRENCY -s "$AB_TIMEOUT" "$AGGREGATOR_PROVER_URL" > $TMP_FILE ; then
8181
REQUESTS_PER_SECOND=$(cat $TMP_FILE | awk '/Requests per second:/ {print $4}')
8282
if [[ $INDEX_RUN -eq 1 ]] ; then
83-
echo "total_requests,concurrency,transactions/request,requests/s" >> $OUT_FILE
83+
echo "total_requests,concurrency,transactions/request,requests/s" >> "$OUT_FILE"
8484
fi
85-
echo "$AB_TOTAL_REQUESTS,$AB_CONCURRENCY,$TRANSACTIONS_PER_REQUEST,$REQUESTS_PER_SECOND" >> $OUT_FILE
85+
echo "$AB_TOTAL_REQUESTS,$AB_CONCURRENCY,$TRANSACTIONS_PER_REQUEST,$REQUESTS_PER_SECOND" >> "$OUT_FILE"
8686
echo ">>>> Success ($REQUESTS_PER_SECOND requests/s)"
8787
else
8888
echo ">>>> Failure"
@@ -93,11 +93,11 @@ RUN_STRESS_TEST() {
9393
}
9494

9595
# Run aggregator benchmark over a range of transactions and concurrency levels
96-
TRANSACTIONS_PER_REQUEST_RANGE=$(seq -s ' ' $TRANSACTIONS_PER_REQUEST_MIN $TRANSACTIONS_PER_REQUEST_STEP $TRANSACTIONS_PER_REQUEST_MAX)
97-
AB_CONCURRENCY_RANGE=$(seq -s ' ' $AB_CONCURRENCY_MIN $AB_CONCURRENCY_STEP $AB_CONCURRENCY_MAX)
98-
TRANSACTIONS_PER_REQUEST_RANGE_LENGTH=$(( $(echo $TRANSACTIONS_PER_REQUEST_RANGE | grep -o " " | wc -l) + 1 ))
99-
AB_CONCURRENCY_RANGE_LENGTH=$(( $(echo $AB_CONCURRENCY_RANGE | grep -o " " | wc -l) + 1 ))
100-
TOTAL_RUN=$(( $TRANSACTIONS_PER_REQUEST_RANGE_LENGTH * $AB_CONCURRENCY_RANGE_LENGTH ))
96+
TRANSACTIONS_PER_REQUEST_RANGE=$(seq -s ' ' "$TRANSACTIONS_PER_REQUEST_MIN" "$TRANSACTIONS_PER_REQUEST_STEP" $TRANSACTIONS_PER_REQUEST_MAX)
97+
AB_CONCURRENCY_RANGE=$(seq -s ' ' "$AB_CONCURRENCY_MIN" "$AB_CONCURRENCY_STEP" "$AB_CONCURRENCY_MAX")
98+
TRANSACTIONS_PER_REQUEST_RANGE_LENGTH=$(( $(echo "$TRANSACTIONS_PER_REQUEST_RANGE" | grep -o " " | wc -l) + 1 ))
99+
AB_CONCURRENCY_RANGE_LENGTH=$(( $(echo "$AB_CONCURRENCY_RANGE" | grep -o " " | wc -l) + 1 ))
100+
TOTAL_RUN=$(( TRANSACTIONS_PER_REQUEST_RANGE_LENGTH * AB_CONCURRENCY_RANGE_LENGTH ))
101101
echo ""
102102
echo "Run aggregator prover benchmark with:"
103103
echo ">> Aggregator endpoint: [$AGGREGATOR_ENDPOINT]"
@@ -113,13 +113,13 @@ echo ""
113113
INDEX_RUN=1
114114
for TRANSACTIONS_PER_REQUEST in $TRANSACTIONS_PER_REQUEST_RANGE; do
115115
for AB_CONCURRENCY in $AB_CONCURRENCY_RANGE; do
116-
RUN_STRESS_TEST $AGGREGATOR_ENDPOINT $TRANSACTIONS_PER_REQUEST $AB_TOTAL_REQUESTS $AB_CONCURRENCY $OUT_FILE $INDEX_RUN $TOTAL_RUN $TRANSACTIONS_FILE
117-
INDEX_RUN=$(( ${INDEX_RUN} + 1))
116+
RUN_STRESS_TEST "$AGGREGATOR_ENDPOINT" "$TRANSACTIONS_PER_REQUEST" "$AB_TOTAL_REQUESTS" "$AB_CONCURRENCY" "$OUT_FILE" $INDEX_RUN "$TOTAL_RUN" "$TRANSACTIONS_FILE"
117+
INDEX_RUN=$(( INDEX_RUN + 1))
118118
done
119119
done
120120

121121
echo ">> Benchmark completed:"
122122
echo ""
123-
cat $OUT_FILE
123+
cat "$OUT_FILE"
124124

125125

0 commit comments

Comments
 (0)