Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteNacked committed Aug 25, 2024
1 parent 5ad141e commit 9610574
Showing 1 changed file with 70 additions and 69 deletions.
139 changes: 70 additions & 69 deletions scripts/benchmarking/run_all_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ for PALLET in "${PALLETS[@]}"; do
then
TASKSET_CMD="taskset -c 2,3,4,5"
echo "[+] Running pallet_gear_builtin benches on fixed 4 cores: 2,3,4,5"
else
TASKSET_CMD="taskset -c 8"
fi

# Get all the extrinsics for the pallet if the pallet is "pallet_gear".
Expand Down Expand Up @@ -180,40 +182,39 @@ for PALLET in "${PALLETS[@]}"; do
fi

WEIGHT_FILE="./${WEIGHTS_OUTPUT}/${PALLET}.rs"
echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE";
#echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE";

#OUTPUT=$(
# $TASKSET_CMD $GEAR benchmark pallet \
# --chain="$chain_spec" \
# --steps=$BENCHMARK_STEPS \
# --repeat=$BENCHMARK_REPEAT \
# --pallet="$PALLET" \
# --extrinsic="$(IFS=, ; echo "${EXTRINSICS[*]}")" \
# --heap-pages=4096 \
# --output="$WEIGHT_FILE" \
# --template=.maintain/frame-weight-template.hbs 2>&1
#)

#if [ $? -ne 0 ]; then
# echo "$OUTPUT" >> "$ERR_FILE"
# echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..."
#fi

# If the pallet is pallet_gear, benchmark the one-time extrinsics.
if [ "$PALLET" == "pallet_gear" ]
then
echo "[+] MSquares Benchmarking $PALLET one-time syscalls with weight file ./${WEIGHTS_OUTPUT}/${PALLET}_onetime.rs";

OUTPUT=$(
$TASKSET_CMD $GEAR benchmark pallet \
--chain="$chain_spec" \
--steps=$BENCHMARK_STEPS \
--repeat=$BENCHMARK_REPEAT \
--steps=$BENCHMARK_STEPS_ONE_TIME_EXTRINSICS \
--repeat=$BENCHMARK_REPEAT_ONE_TIME_EXTRINSICS \
--pallet="$PALLET" \
--extrinsic="$(IFS=, ; echo "${EXTRINSICS[*]}")" \
--extrinsic="gr_exit" \
--heap-pages=4096 \
--output="$WEIGHT_FILE" \
--template=.maintain/frame-weight-template.hbs 2>&1
)

if [ $? -ne 0 ]; then
echo "$OUTPUT" >> "$ERR_FILE"
echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..."
fi

# If the pallet is pallet_gear, benchmark the one-time extrinsics.
if [ "$PALLET" == "pallet_gear" ]
then
echo "[+] Benchmarking $PALLET one-time syscalls with weight file ./${WEIGHTS_OUTPUT}/${PALLET}_onetime.rs";
OUTPUT=$(
$TASKSET_CMD $GEAR benchmark pallet \
--chain="$chain_spec" \
--steps=$BENCHMARK_STEPS_ONE_TIME_EXTRINSICS \
--repeat=$BENCHMARK_REPEAT_ONE_TIME_EXTRINSICS \
--pallet="$PALLET" \
--extrinsic="$(IFS=', '; echo "${ONE_TIME_EXTRINSICS[*]}")" \
--heap-pages=4096 \
--output="./${WEIGHTS_OUTPUT}/${PALLET}_onetime.rs" \
--template=.maintain/frame-weight-template.hbs 2>&1
)
--json
#--output-analysis=min-squares

if [ $? -ne 0 ]; then
echo "$OUTPUT" >> "$ERR_FILE"
Expand All @@ -222,43 +223,43 @@ for PALLET in "${PALLETS[@]}"; do
fi
done

if [ "$skip_machine_benchmark" != true ]
then
echo "[+] Benchmarking the machine..."
OUTPUT=$(
$TASKSET_CMD $GEAR benchmark machine --chain=$chain_spec --allow-fail 2>&1
)
# In any case don't write errors to the error file since they're not benchmarking errors.
echo "[x] Machine benchmark:\n$OUTPUT"
echo $OUTPUT >> $MACHINE_OUTPUT
fi

# If `-s` is used, run the storage benchmark.
if [ ! -z "$storage_folder" ]; then
OUTPUT=$(
$TASKSET_CMD $GEAR benchmark storage \
--chain=$chain_spec \
--state-version=1 \
--warmups=10 \
--base-path=$storage_folder \
--weight-path=./$STORAGE_OUTPUT 2>&1
)
if [ $? -ne 0 ]; then
echo "$OUTPUT" >> "$ERR_FILE"
echo "[-] Failed the storage benchmark. Error written to $ERR_FILE; continuing..."
fi
else
unset storage_folder
fi

# Merge pallet_gear weights.
./scripts/benchmarking/merge_outputs.sh

# Check if the error file exists.
if [ -f "$ERR_FILE" ]; then
echo "[-] Some benchmarks failed. See: $ERR_FILE"
exit 1
else
echo "[+] All benchmarks passed."
exit 0
fi
#if [ "$skip_machine_benchmark" != true ]
#then
# echo "[+] Benchmarking the machine..."
# OUTPUT=$(
# $TASKSET_CMD $GEAR benchmark machine --chain=$chain_spec --allow-fail 2>&1
# )
# # In any case don't write errors to the error file since they're not benchmarking errors.
# echo "[x] Machine benchmark:\n$OUTPUT"
# echo $OUTPUT >> $MACHINE_OUTPUT
#fi
#
## If `-s` is used, run the storage benchmark.
#if [ ! -z "$storage_folder" ]; then
# OUTPUT=$(
# $TASKSET_CMD $GEAR benchmark storage \
# --chain=$chain_spec \
# --state-version=1 \
# --warmups=10 \
# --base-path=$storage_folder \
# --weight-path=./$STORAGE_OUTPUT 2>&1
# )
# if [ $? -ne 0 ]; then
# echo "$OUTPUT" >> "$ERR_FILE"
# echo "[-] Failed the storage benchmark. Error written to $ERR_FILE; continuing..."
# fi
#else
# unset storage_folder
#fi
#
## Merge pallet_gear weights.
#./scripts/benchmarking/merge_outputs.sh
#
## Check if the error file exists.
#if [ -f "$ERR_FILE" ]; then
# echo "[-] Some benchmarks failed. See: $ERR_FILE"
# exit 1
#else
# echo "[+] All benchmarks passed."
# exit 0
#fi

0 comments on commit 9610574

Please sign in to comment.