Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit fced297

Browse files
gui1117Parity Benchmarking Botshawntabrizi
authored
Benchmarking also benchmark for decoding the call (#9343)
* benchmark for decoding of call * better names * fix benchmarks * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_lottery --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/lottery/src/weights.rs --template=./.maintain/frame-weight-template.hbs * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_utility --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/utility/src/weights.rs --template=./.maintain/frame-weight-template.hbs * cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=frame_system --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/system/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Update frame/system/src/weights.rs Co-authored-by: Parity Benchmarking Bot <admin@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
1 parent 7960c9e commit fced297

File tree

5 files changed

+76
-63
lines changed

5 files changed

+76
-63
lines changed

frame/benchmarking/src/lib.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,21 @@ macro_rules! benchmarks_iter {
302302
{ $( $where_clause )* }
303303
( $( $names )* )
304304
( $( $names_extra )* )
305-
$name { $( $code )* }: {
305+
$name {
306+
$( $code )*
307+
let __benchmarked_call_encoded = $crate::frame_support::codec::Encode::encode(
308+
&<Call<T $(, $instance )?>>::$dispatch($( $arg ),*)
309+
);
310+
}: {
311+
let call_decoded = <
312+
Call<T $(, $instance )?>
313+
as $crate::frame_support::codec::Decode
314+
>::decode(&mut &__benchmarked_call_encoded[..])
315+
.expect("call is encoded above, encoding must be correct");
316+
306317
<
307318
Call<T $(, $instance)? > as $crate::frame_support::traits::UnfilteredDispatchable
308-
>::dispatch_bypass_filter(
309-
Call::<T $(, $instance)? >::$dispatch($($arg),*), $origin.into()
310-
)?;
319+
>::dispatch_bypass_filter(call_decoded, $origin.into())?;
311320
}
312321
verify $postcode
313322
$( $rest )*

frame/contracts/src/benchmarking/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ benchmarks! {
727727
let origin = RawOrigin::Signed(instance.caller.clone());
728728
assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into());
729729
assert_eq!(T::Currency::total_balance(&instance.account_id), Endow::max::<T>());
730-
}: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![])
730+
}: call(origin, instance.addr.clone(), 0u32.into(), Weight::max_value(), vec![])
731731
verify {
732732
if r > 0 {
733733
assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into());

frame/lottery/src/weights.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
//! Autogenerated weights for pallet_lottery
1919
//!
20-
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
21-
//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
20+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21+
//! DATE: 2021-07-14, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
2222
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
2323
2424
// Executed Command:
@@ -57,33 +57,33 @@ pub trait WeightInfo {
5757
pub struct SubstrateWeight<T>(PhantomData<T>);
5858
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
5959
fn buy_ticket() -> Weight {
60-
(71_604_000 as Weight)
60+
(74_856_000 as Weight)
6161
.saturating_add(T::DbWeight::get().reads(6 as Weight))
6262
.saturating_add(T::DbWeight::get().writes(4 as Weight))
6363
}
6464
fn set_calls(n: u32, ) -> Weight {
65-
(15_015_000 as Weight)
66-
// Standard Error: 5_000
67-
.saturating_add((301_000 as Weight).saturating_mul(n as Weight))
65+
(15_549_000 as Weight)
66+
// Standard Error: 7_000
67+
.saturating_add((281_000 as Weight).saturating_mul(n as Weight))
6868
.saturating_add(T::DbWeight::get().writes(1 as Weight))
6969
}
7070
fn start_lottery() -> Weight {
71-
(58_855_000 as Weight)
71+
(58_904_000 as Weight)
7272
.saturating_add(T::DbWeight::get().reads(3 as Weight))
7373
.saturating_add(T::DbWeight::get().writes(3 as Weight))
7474
}
7575
fn stop_repeat() -> Weight {
76-
(7_524_000 as Weight)
76+
(7_714_000 as Weight)
7777
.saturating_add(T::DbWeight::get().reads(1 as Weight))
7878
.saturating_add(T::DbWeight::get().writes(1 as Weight))
7979
}
8080
fn on_initialize_end() -> Weight {
81-
(114_766_000 as Weight)
81+
(117_420_000 as Weight)
8282
.saturating_add(T::DbWeight::get().reads(6 as Weight))
8383
.saturating_add(T::DbWeight::get().writes(4 as Weight))
8484
}
8585
fn on_initialize_repeat() -> Weight {
86-
(119_402_000 as Weight)
86+
(123_035_000 as Weight)
8787
.saturating_add(T::DbWeight::get().reads(7 as Weight))
8888
.saturating_add(T::DbWeight::get().writes(5 as Weight))
8989
}
@@ -92,33 +92,33 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
9292
// For backwards compatibility and tests
9393
impl WeightInfo for () {
9494
fn buy_ticket() -> Weight {
95-
(71_604_000 as Weight)
95+
(74_856_000 as Weight)
9696
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
9797
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
9898
}
9999
fn set_calls(n: u32, ) -> Weight {
100-
(15_015_000 as Weight)
101-
// Standard Error: 5_000
102-
.saturating_add((301_000 as Weight).saturating_mul(n as Weight))
100+
(15_549_000 as Weight)
101+
// Standard Error: 7_000
102+
.saturating_add((281_000 as Weight).saturating_mul(n as Weight))
103103
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
104104
}
105105
fn start_lottery() -> Weight {
106-
(58_855_000 as Weight)
106+
(58_904_000 as Weight)
107107
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
108108
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
109109
}
110110
fn stop_repeat() -> Weight {
111-
(7_524_000 as Weight)
111+
(7_714_000 as Weight)
112112
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
113113
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
114114
}
115115
fn on_initialize_end() -> Weight {
116-
(114_766_000 as Weight)
116+
(117_420_000 as Weight)
117117
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
118118
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
119119
}
120120
fn on_initialize_repeat() -> Weight {
121-
(119_402_000 as Weight)
121+
(123_035_000 as Weight)
122122
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
123123
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
124124
}

frame/system/src/weights.rs

+28-24
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
//! Autogenerated weights for frame_system
1919
//!
20-
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
21-
//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
20+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21+
//! DATE: 2021-07-20, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
2222
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
2323
2424
// Executed Command:
@@ -57,78 +57,82 @@ pub trait WeightInfo {
5757
/// Weights for frame_system using the Substrate node and recommended hardware.
5858
pub struct SubstrateWeight<T>(PhantomData<T>);
5959
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
60-
fn remark(_b: u32, ) -> Weight {
61-
(1_038_000 as Weight)
60+
fn remark(b: u32, ) -> Weight {
61+
(0 as Weight)
62+
// Standard Error: 0
63+
.saturating_add((1_000 as Weight).saturating_mul(b as Weight))
6264
}
6365
fn remark_with_event(b: u32, ) -> Weight {
64-
(5_246_000 as Weight)
66+
(16_569_000 as Weight)
6567
// Standard Error: 0
66-
.saturating_add((1_000 as Weight).saturating_mul(b as Weight))
68+
.saturating_add((2_000 as Weight).saturating_mul(b as Weight))
6769
}
6870
fn set_heap_pages() -> Weight {
69-
(1_586_000 as Weight)
71+
(1_783_000 as Weight)
7072
.saturating_add(T::DbWeight::get().writes(1 as Weight))
7173
}
7274
fn set_changes_trie_config() -> Weight {
73-
(7_181_000 as Weight)
75+
(7_727_000 as Weight)
7476
.saturating_add(T::DbWeight::get().reads(1 as Weight))
7577
.saturating_add(T::DbWeight::get().writes(2 as Weight))
7678
}
7779
fn set_storage(i: u32, ) -> Weight {
7880
(0 as Weight)
7981
// Standard Error: 0
80-
.saturating_add((568_000 as Weight).saturating_mul(i as Weight))
82+
.saturating_add((875_000 as Weight).saturating_mul(i as Weight))
8183
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
8284
}
8385
fn kill_storage(i: u32, ) -> Weight {
84-
(2_278_000 as Weight)
86+
(4_216_000 as Weight)
8587
// Standard Error: 0
86-
.saturating_add((423_000 as Weight).saturating_mul(i as Weight))
88+
.saturating_add((555_000 as Weight).saturating_mul(i as Weight))
8789
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
8890
}
8991
fn kill_prefix(p: u32, ) -> Weight {
90-
(8_243_000 as Weight)
92+
(14_558_000 as Weight)
9193
// Standard Error: 1_000
92-
.saturating_add((795_000 as Weight).saturating_mul(p as Weight))
94+
.saturating_add((781_000 as Weight).saturating_mul(p as Weight))
9395
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
9496
}
9597
}
9698

9799
// For backwards compatibility and tests
98100
impl WeightInfo for () {
99-
fn remark(_b: u32, ) -> Weight {
100-
(1_038_000 as Weight)
101+
fn remark(b: u32, ) -> Weight {
102+
(0 as Weight)
103+
// Standard Error: 0
104+
.saturating_add((1_000 as Weight).saturating_mul(b as Weight))
101105
}
102106
fn remark_with_event(b: u32, ) -> Weight {
103-
(5_246_000 as Weight)
107+
(16_569_000 as Weight)
104108
// Standard Error: 0
105-
.saturating_add((1_000 as Weight).saturating_mul(b as Weight))
109+
.saturating_add((2_000 as Weight).saturating_mul(b as Weight))
106110
}
107111
fn set_heap_pages() -> Weight {
108-
(1_586_000 as Weight)
112+
(1_783_000 as Weight)
109113
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
110114
}
111115
fn set_changes_trie_config() -> Weight {
112-
(7_181_000 as Weight)
116+
(7_727_000 as Weight)
113117
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
114118
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
115119
}
116120
fn set_storage(i: u32, ) -> Weight {
117121
(0 as Weight)
118122
// Standard Error: 0
119-
.saturating_add((568_000 as Weight).saturating_mul(i as Weight))
123+
.saturating_add((875_000 as Weight).saturating_mul(i as Weight))
120124
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
121125
}
122126
fn kill_storage(i: u32, ) -> Weight {
123-
(2_278_000 as Weight)
127+
(4_216_000 as Weight)
124128
// Standard Error: 0
125-
.saturating_add((423_000 as Weight).saturating_mul(i as Weight))
129+
.saturating_add((555_000 as Weight).saturating_mul(i as Weight))
126130
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
127131
}
128132
fn kill_prefix(p: u32, ) -> Weight {
129-
(8_243_000 as Weight)
133+
(14_558_000 as Weight)
130134
// Standard Error: 1_000
131-
.saturating_add((795_000 as Weight).saturating_mul(p as Weight))
135+
.saturating_add((781_000 as Weight).saturating_mul(p as Weight))
132136
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
133137
}
134138
}

frame/utility/src/weights.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
//! Autogenerated weights for pallet_utility
1919
//!
20-
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
21-
//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
20+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21+
//! DATE: 2021-07-14, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
2222
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
2323
2424
// Executed Command:
@@ -54,33 +54,33 @@ pub trait WeightInfo {
5454
pub struct SubstrateWeight<T>(PhantomData<T>);
5555
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
5656
fn batch(c: u32, ) -> Weight {
57-
(14_618_000 as Weight)
58-
// Standard Error: 0
59-
.saturating_add((610_000 as Weight).saturating_mul(c as Weight))
57+
(20_779_000 as Weight)
58+
// Standard Error: 1_000
59+
.saturating_add((1_080_000 as Weight).saturating_mul(c as Weight))
6060
}
6161
fn as_derivative() -> Weight {
62-
(3_175_000 as Weight)
62+
(3_994_000 as Weight)
6363
}
6464
fn batch_all(c: u32, ) -> Weight {
65-
(14_561_000 as Weight)
66-
// Standard Error: 0
67-
.saturating_add((1_013_000 as Weight).saturating_mul(c as Weight))
65+
(22_183_000 as Weight)
66+
// Standard Error: 1_000
67+
.saturating_add((1_506_000 as Weight).saturating_mul(c as Weight))
6868
}
6969
}
7070

7171
// For backwards compatibility and tests
7272
impl WeightInfo for () {
7373
fn batch(c: u32, ) -> Weight {
74-
(14_618_000 as Weight)
75-
// Standard Error: 0
76-
.saturating_add((610_000 as Weight).saturating_mul(c as Weight))
74+
(20_779_000 as Weight)
75+
// Standard Error: 1_000
76+
.saturating_add((1_080_000 as Weight).saturating_mul(c as Weight))
7777
}
7878
fn as_derivative() -> Weight {
79-
(3_175_000 as Weight)
79+
(3_994_000 as Weight)
8080
}
8181
fn batch_all(c: u32, ) -> Weight {
82-
(14_561_000 as Weight)
83-
// Standard Error: 0
84-
.saturating_add((1_013_000 as Weight).saturating_mul(c as Weight))
82+
(22_183_000 as Weight)
83+
// Standard Error: 1_000
84+
.saturating_add((1_506_000 as Weight).saturating_mul(c as Weight))
8585
}
8686
}

0 commit comments

Comments
 (0)