Skip to content

Commit ce945e0

Browse files
committed
feat: add help and check requirements
1 parent 542ebc2 commit ce945e0

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

mithril-test-lab/benchmark/aggregator-prover/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ export AB_CONCURRENCY_MAX=100
2424
export AB_CONCURRENCY_STEP=50
2525
```
2626

27-
28-
Than, run the benchmarks:
27+
Then, run the benchmarks:
2928
```bash
3029
./benchmark-aggregator-prover.sh
3130
```
3231

3332
Which will output these type of results:
3433
```bash
35-
Using the default OUT_FILE: benchmark.csv
34+
MITHRIL AGGREGATOR PROVER ROUTE BENCHMARK
3635

37-
Run aggregator prover benchmark with:
3836
>> Aggregator endpoint: https://aggregator.testing-mainnet.api.mithril.network/aggregator
3937
>> Aggregator route: /proof/cardano-transaction
4038
>> Transactions file: transactions-mainnet.txt

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

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,48 @@
22

33
set -e
44

5+
check_requirements() {
6+
which ab >/dev/null ||
7+
error "It seems 'ab' is not installed or not in the path.";
8+
9+
}
10+
11+
error() {
12+
echo
13+
echo "ERROR: $1";
14+
exit 1;
15+
}
16+
17+
display_help() {
18+
echo
19+
if [ -n "${1-""}" ]; then echo "ERROR: ${1}"; echo; fi
20+
echo "HELP"
21+
echo "$0"
22+
echo
23+
echo "Benchmark a Mithril aggregator prover route"
24+
echo
25+
echo "Usage: $0"
26+
echo
27+
echo "Available configuration environment variables:"
28+
echo "- DEBUG: activate debug output"
29+
echo "- AGGREGATOR_ENDPOINT: the aggregator endpoint"
30+
echo "- TRANSACTIONS_FILE: the file containing the transactions hashes"
31+
echo "- TRANSACTIONS_PER_REQUEST_MIN: the minimum number of transactions per request"
32+
echo "- TRANSACTIONS_PER_REQUEST_MAX: the maximum number of transactions per request"
33+
echo "- TRANSACTIONS_PER_REQUEST_STEP: the step between each number of transactions per request"
34+
echo "- AB_TOTAL_REQUESTS: the total number of requests"
35+
echo "- AB_CONCURRENCY_MIN: the minimum concurrency level"
36+
echo "- AB_CONCURRENCY_MAX: the maximum concurrency level"
37+
echo "- AB_CONCURRENCY_STEP: the step between each concurrency level"
38+
echo
39+
exit 1;
40+
}
41+
42+
echo ""
43+
echo "MITHRIL AGGREGATOR PROVER ROUTE BENCHMARK"
44+
45+
check_requirements
46+
547
# Debug mode
648
if [ -v DEBUG ]; then
749
set -x
@@ -11,13 +53,11 @@ AGGREGATOR_PROVER_ROUTE="/proof/cardano-transaction"
1153

1254
# Check if all env vars are set
1355
if [ -z "${AGGREGATOR_ENDPOINT}" ]; then
14-
echo "Missing environment variable: AGGREGATOR_ENDPOINT" >/dev/stderr
15-
exit 1
56+
display_help "Missing environment variable: AGGREGATOR_ENDPOINT"
1657
fi
1758

1859
if [ -z "${TRANSACTIONS_FILE}" ]; then
19-
echo "Missing environment variable: TRANSACTIONS_FILE" >/dev/stderr
20-
exit 1
60+
display_help "Missing environment variable: TRANSACTIONS_FILE"
2161
fi
2262

2363
if [ -z "${TRANSACTIONS_PER_REQUEST_MIN}" ]; then
@@ -58,7 +98,6 @@ fi
5898
if [ -z "${OUT_FILE}" ]; then
5999
OUT_FILE="benchmark.csv"
60100
rm -f $OUT_FILE
61-
echo "Using the default OUT_FILE: $OUT_FILE"
62101
fi
63102
mkdir -p "$(dirname "$OUT_FILE")"
64103

@@ -100,8 +139,7 @@ AB_CONCURRENCY_RANGE=$(seq -s ' ' "$AB_CONCURRENCY_MIN" "$AB_CONCURRENCY_STEP" "
100139
TRANSACTIONS_PER_REQUEST_RANGE_LENGTH=$(( $(echo "$TRANSACTIONS_PER_REQUEST_RANGE" | grep -o " " | wc -l) + 1 ))
101140
AB_CONCURRENCY_RANGE_LENGTH=$(( $(echo "$AB_CONCURRENCY_RANGE" | grep -o " " | wc -l) + 1 ))
102141
TOTAL_RUN=$(( TRANSACTIONS_PER_REQUEST_RANGE_LENGTH * AB_CONCURRENCY_RANGE_LENGTH ))
103-
echo ""
104-
echo "Run aggregator prover benchmark with:"
142+
echo
105143
echo ">> Aggregator endpoint: $AGGREGATOR_ENDPOINT"
106144
echo ">> Aggregator route: $AGGREGATOR_PROVER_ROUTE"
107145
echo ">> Transactions file: $TRANSACTIONS_FILE"
@@ -111,7 +149,7 @@ echo ">> AB concurrency range: [$AB_CONCURRENCY_RANGE]"
111149
echo ">> AB total requests per run: [$AB_TOTAL_REQUESTS]"
112150
echo ">> AB total runs: $TOTAL_RUN"
113151
echo ">> Output file: $OUT_FILE"
114-
echo ""
152+
echo
115153

116154
INDEX_RUN=1
117155
for TRANSACTIONS_PER_REQUEST in $TRANSACTIONS_PER_REQUEST_RANGE; do

0 commit comments

Comments
 (0)