forked from polkadot-evm/frontier
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark.sh
executable file
·47 lines (39 loc) · 1.16 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# This script can be used for running frontier's benchmarks.
#
# The frontier binary is required to be compiled with --features=runtime-benchmarks
# in release mode.
set -e
BINARY="./target/release/frontier-template-node"
function choose_and_bench {
readarray -t options < <(${BINARY} benchmark pallet --list | sed 1d)
options+=('EXIT')
select opt in "${options[@]}"; do
IFS=', ' read -ra parts <<< "${opt}"
echo "${parts[0]} -- ${parts[1]}"
[[ "${opt}" == 'EXIT' ]] && exit 0
bench "${parts[0]}" "${parts[1]}"
break
done
}
function bench {
echo "benchmarking ${1}::${2}"
WASMTIME_BACKTRACE_DETAILS=1 ${BINARY} benchmark pallet \
--chain=dev \
--steps=50 \
--repeat=20 \
--pallet="${1}" \
--extrinsic="${2}" \
--execution=wasm \
--wasm-execution=compiled \
--output=weights.rs \
--template=./benchmarking/frame-weight-template.hbs
}
if [[ $# -eq 1 && "${1}" == "--help" ]]; then
echo "USAGE:"
echo " ${0} [<pallet> <extrinsic>]"
elif [[ $# -ne 2 ]]; then
choose_and_bench
else
bench "${1}" "${2}"
fi