This repository has been archived by the owner on May 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.sh
executable file
·115 lines (107 loc) · 4.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env bash
PRIME_COMMAND=$1
: ${PRIME_COMMAND:=""}
function generate_weight() {
# params:
#--chain # Configurable Chain Spec
#--execution # Always test with Wasm
#--wasm-execution # Always used `wasm-time`
#--pallet # Select the pallet
#--extrinsic # Select the extrinsic
#--steps # Number of samples across component ranges
#--repeat # Number of times we repeat a benchmark
#--header # Specify header file to insert into head of output file
#--output # Output benchmark results into a folder or file
./target/debug/tea-camellia benchmark \
--chain=dev \
--execution=wasm \
--wasm-execution=compiled \
--pallet="$PALLET_NAME" \
--extrinsic="$EXTRINSI_NAME" \
--steps=$BENCHMARK_STEP \
--repeat=$BENCHMARK_REPEAT \
--heap-pages=4096 \
--header=./file_header.txt \
--output="runtime/src/weights/${PALLET_NAME}.rs"
}
function generate_template() {
# params:
#--chain # Configurable Chain Spec
#--execution # Always test with Wasm
#--wasm-execution # Always used `wasm-time`
#--pallet # Select the pallet
#--extrinsic # Select the extrinsic
#--steps # Number of samples across component ranges
#--repeat # Number of times we repeat a benchmark
#--header # Specify header file to insert into head of output file
#--output # Output benchmark results into a folder or file
#--template # Template file to generate `WeightInfo` trait and implement
./target/release/tea-camellia benchmark \
--chain=dev \
--execution=wasm \
--wasm-execution=compiled \
--pallet="$PALLET_NAME" \
--extrinsic="$EXTRINSI_NAME" \
--steps=$BENCHMARK_STEP \
--repeat=$BENCHMARK_REPEAT \
--heap-pages=4096 \
--header="./file_header.txt" \
--output="pallets/${PACKAGE_NAME}/src/weights.rs" \
--template="./.maintain/frame-weight-template.hbs"
}
if [ $PRIME_COMMAND = "build" ]; then
cargo build --release --features runtime-benchmarks
elif [ $PRIME_COMMAND = "test" ]; then
cargo test --features runtime-benchmarks
elif [ $PRIME_COMMAND = "weight" ]; then
PALLET_NAME=$2
: ${PALLET_NAME:="pallet_tea"}
EXTRINSI_NAME=$3
: ${EXTRINSI_NAME:="*"}
BENCHMARK_STEP=$4
: ${BENCHMARK_STEP:=50}
BENCHMARK_REPEAT=$5
: ${BENCHMARK_REPEAT:=20}
generate_weight
elif [ $PRIME_COMMAND = "template" ]; then
PALLET_NAME=$2
: ${PALLET_NAME:="pallet_tea"}
PACKAGE_NAME=$3
: ${PACKAGE_NAME:="tea"}
EXTRINSI_NAME=$4
: ${EXTRINSI_NAME:="*"}
BENCHMARK_STEP=$5
: ${BENCHMARK_STEP:=50}
BENCHMARK_REPEAT=$6
: ${BENCHMARK_REPEAT:=20}
generate_template
elif [ $PRIME_COMMAND = "batch_weight" ]; then
EXTRINSI_NAME="*"
BENCHMARK_STEP=$2
: ${BENCHMARK_STEP:=50}
BENCHMARK_REPEAT=$3
: ${BENCHMARK_REPEAT:=20}
PALLET_NAME=frame_system && generate_weight
PALLET_NAME=pallet_grandpa && generate_weight
PALLET_NAME=pallet_timestamp && generate_weight
PALLET_NAME=pallet_balances && generate_weight
PALLET_NAME=pallet_babe && generate_weight
PALLET_NAME=pallet_session && generate_weight
PALLET_NAME=pallet_staking && generate_weight
PALLET_NAME=pallet_offences && generate_weight
PALLET_NAME=pallet_im_online && generate_weight
PALLET_NAME=pallet_elections_phragmen && generate_weight
PALLET_NAME=pallet_election_provider_multi_phase && generate_weight
PALLET_NAME=pallet_collective && generate_weight
PALLET_NAME=pallet_membership && generate_weight
PALLET_NAME=pallet_scheduler && generate_weight
PALLET_NAME=pallet_democracy && generate_weight
PALLET_NAME=pallet_utility && generate_weight
PALLET_NAME=pallet_multisig && generate_weight
PALLET_NAME=pallet_identity && generate_weight
PALLET_NAME=pallet_tea && generate_weight
PALLET_NAME=pallet_cml && generate_weight
PALLET_NAME=pallet_auction && generate_weight
else
echo "unknown command, supported commands: build, test, weight, template"
fi