Skip to content

Commit

Permalink
Benchmarking: Calculate weights for 1bb052e (#391)
Browse files Browse the repository at this point in the history
* change(pallet-communities-manager): add create_memberships method

* fix(kreivo-runtime): adjust imports

* change(pallet-communities-manager): add price to create_memberships

* [ci] calculate weights

* change(pallet-communities-manager): check max weights against current benchmarking

---------

Co-authored-by: Pablo Andrés Dorado Suárez <[email protected]>
Co-authored-by: pandres95 <[email protected]>
  • Loading branch information
3 people authored May 9, 2024
1 parent 6e0b325 commit e4bdc26
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 77 deletions.
8 changes: 7 additions & 1 deletion pallets/communities-manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ fn weights() {

let mut total = Weight::zero();

let calls = vec![("register", SubstrateWeight::<Test>::register())];
let calls = vec![
("register", SubstrateWeight::<Test>::register()),
(
"create_memberships(100)",
SubstrateWeight::<Test>::create_memberships(100),
),
];

for (function, weight) in calls {
println!("{function}: {weight:?}",);
Expand Down
78 changes: 56 additions & 22 deletions pallets/communities-manager/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,39 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 117_045_000 picoseconds.
Weight::from_parts(166_053_000, 0)
// Minimum execution time: 115_705_000 picoseconds.
Weight::from_parts(140_658_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(14))
}

fn create_memberships(_: u16, ) -> Weight {
/// Storage: `CommunityMemberships::Item` (r:1023 w:1023)
/// Proof: `CommunityMemberships::Item` (`max_values`: None, `max_size`: Some(859), added: 3334, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Collection` (r:1 w:1)
/// Proof: `CommunityMemberships::Collection` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::CollectionConfigOf` (r:1 w:0)
/// Proof: `CommunityMemberships::CollectionConfigOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::ItemConfigOf` (r:1023 w:1023)
/// Proof: `CommunityMemberships::ItemConfigOf` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Account` (r:0 w:1023)
/// Proof: `CommunityMemberships::Account` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::ItemPriceOf` (r:0 w:1023)
/// Proof: `CommunityMemberships::ItemPriceOf` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// The range of component `q` is `[1, 1024]`.
fn create_memberships(q: u16, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 117_045_000 picoseconds.
Weight::from_parts(166_053_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(14))
// Measured: `368`
// Estimated: `3547 + q * (3334 ±0)`
// Minimum execution time: 87_026_000 picoseconds.
Weight::from_parts(110_670_000, 0)
.saturating_add(Weight::from_parts(0, 3547))
// Standard Error: 331_618
.saturating_add(Weight::from_parts(83_810_638, 0).saturating_mul(q.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(q.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(q.into())))
.saturating_add(Weight::from_parts(0, 3334).saturating_mul(q.into()))
}
}

Expand Down Expand Up @@ -98,21 +115,38 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 117_045_000 picoseconds.
Weight::from_parts(166_053_000, 0)
// Minimum execution time: 115_705_000 picoseconds.
Weight::from_parts(140_658_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().writes(14))
}

fn create_memberships(_: u16, ) -> Weight {
/// Storage: `CommunityMemberships::Item` (r:1023 w:1023)
/// Proof: `CommunityMemberships::Item` (`max_values`: None, `max_size`: Some(859), added: 3334, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Collection` (r:1 w:1)
/// Proof: `CommunityMemberships::Collection` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::CollectionConfigOf` (r:1 w:0)
/// Proof: `CommunityMemberships::CollectionConfigOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::ItemConfigOf` (r:1023 w:1023)
/// Proof: `CommunityMemberships::ItemConfigOf` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Account` (r:0 w:1023)
/// Proof: `CommunityMemberships::Account` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::ItemPriceOf` (r:0 w:1023)
/// Proof: `CommunityMemberships::ItemPriceOf` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// The range of component `q` is `[1, 1024]`.
fn create_memberships(q: u16, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 117_045_000 picoseconds.
Weight::from_parts(166_053_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().writes(14))
// Measured: `368`
// Estimated: `3547 + q * (3334 ±0)`
// Minimum execution time: 87_026_000 picoseconds.
Weight::from_parts(110_670_000, 0)
.saturating_add(Weight::from_parts(0, 3547))
// Standard Error: 331_618
.saturating_add(Weight::from_parts(83_810_638, 0).saturating_mul(q.into()))
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(q.into())))
.saturating_add(RocksDbWeight::get().writes(1))
.saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(q.into())))
.saturating_add(Weight::from_parts(0, 3334).saturating_mul(q.into()))
}
}
46 changes: 23 additions & 23 deletions runtime/kreivo/src/weights/pallet_communities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Autogenerated weights for `pallet_communities`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-04-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-05-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `virto-builder`, CPU: `Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("kreivo-local")`, DB CACHE: 1024
Expand Down Expand Up @@ -45,8 +45,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `56`
// Estimated: `3593`
// Minimum execution time: 58_161_000 picoseconds.
Weight::from_parts(69_157_000, 0)
// Minimum execution time: 39_254_000 picoseconds.
Weight::from_parts(44_989_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -59,8 +59,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `122`
// Estimated: `4087`
// Minimum execution time: 57_556_000 picoseconds.
Weight::from_parts(59_165_000, 0)
// Minimum execution time: 39_264_000 picoseconds.
Weight::from_parts(59_388_000, 0)
.saturating_add(Weight::from_parts(0, 4087))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -73,8 +73,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `3484`
// Minimum execution time: 33_456_000 picoseconds.
Weight::from_parts(37_220_000, 0)
// Minimum execution time: 24_894_000 picoseconds.
Weight::from_parts(36_775_000, 0)
.saturating_add(Weight::from_parts(0, 3484))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand Down Expand Up @@ -105,8 +105,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `880`
// Estimated: `9846`
// Minimum execution time: 346_154_000 picoseconds.
Weight::from_parts(389_196_000, 0)
// Minimum execution time: 245_334_000 picoseconds.
Weight::from_parts(360_487_000, 0)
.saturating_add(Weight::from_parts(0, 9846))
.saturating_add(T::DbWeight::get().reads(13))
.saturating_add(T::DbWeight::get().writes(13))
Expand Down Expand Up @@ -135,8 +135,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `1006`
// Estimated: `12798`
// Minimum execution time: 372_760_000 picoseconds.
Weight::from_parts(383_094_000, 0)
// Minimum execution time: 317_361_000 picoseconds.
Weight::from_parts(465_610_000, 0)
.saturating_add(Weight::from_parts(0, 12798))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(10))
Expand All @@ -151,8 +151,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `717`
// Estimated: `6894`
// Minimum execution time: 138_465_000 picoseconds.
Weight::from_parts(216_155_000, 0)
// Minimum execution time: 134_868_000 picoseconds.
Weight::from_parts(158_292_000, 0)
.saturating_add(Weight::from_parts(0, 6894))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -167,8 +167,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `755`
// Estimated: `6894`
// Minimum execution time: 178_550_000 picoseconds.
Weight::from_parts(224_353_000, 0)
// Minimum execution time: 198_275_000 picoseconds.
Weight::from_parts(202_790_000, 0)
.saturating_add(Weight::from_parts(0, 6894))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -195,8 +195,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `3035`
// Estimated: `6148`
// Minimum execution time: 374_166_000 picoseconds.
Weight::from_parts(521_406_000, 0)
// Minimum execution time: 393_947_000 picoseconds.
Weight::from_parts(476_186_000, 0)
.saturating_add(Weight::from_parts(0, 6148))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(6))
Expand All @@ -215,8 +215,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `2898`
// Estimated: `4365`
// Minimum execution time: 186_847_000 picoseconds.
Weight::from_parts(249_529_000, 0)
// Minimum execution time: 178_506_000 picoseconds.
Weight::from_parts(241_482_000, 0)
.saturating_add(Weight::from_parts(0, 4365))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -235,8 +235,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `1082`
// Estimated: `8123`
// Minimum execution time: 204_012_000 picoseconds.
Weight::from_parts(219_951_000, 0)
// Minimum execution time: 164_095_000 picoseconds.
Weight::from_parts(219_358_000, 0)
.saturating_add(Weight::from_parts(0, 8123))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -247,8 +247,8 @@ impl<T: frame_system::Config> pallet_communities::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `3484`
// Minimum execution time: 48_041_000 picoseconds.
Weight::from_parts(51_107_000, 0)
// Minimum execution time: 33_857_000 picoseconds.
Weight::from_parts(47_890_000, 0)
.saturating_add(Weight::from_parts(0, 3484))
.saturating_add(T::DbWeight::get().reads(1))
}
Expand Down
41 changes: 29 additions & 12 deletions runtime/kreivo/src/weights/pallet_communities_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Autogenerated weights for `pallet_communities_manager`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-04-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-05-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `virto-builder`, CPU: `Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("kreivo-local")`, DB CACHE: 1024
Expand Down Expand Up @@ -67,21 +67,38 @@ impl<T: frame_system::Config> pallet_communities_manager::WeightInfo for WeightI
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 172_690_000 picoseconds.
Weight::from_parts(178_773_000, 0)
// Minimum execution time: 115_705_000 picoseconds.
Weight::from_parts(140_658_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(14))
}

fn create_memberships(_: u16, ) -> Weight {
/// Storage: `CommunityMemberships::Item` (r:1023 w:1023)
/// Proof: `CommunityMemberships::Item` (`max_values`: None, `max_size`: Some(859), added: 3334, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Collection` (r:1 w:1)
/// Proof: `CommunityMemberships::Collection` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::CollectionConfigOf` (r:1 w:0)
/// Proof: `CommunityMemberships::CollectionConfigOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::ItemConfigOf` (r:1023 w:1023)
/// Proof: `CommunityMemberships::ItemConfigOf` (`max_values`: None, `max_size`: Some(46), added: 2521, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Account` (r:0 w:1023)
/// Proof: `CommunityMemberships::Account` (`max_values`: None, `max_size`: Some(86), added: 2561, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::ItemPriceOf` (r:0 w:1023)
/// Proof: `CommunityMemberships::ItemPriceOf` (`max_values`: None, `max_size`: Some(87), added: 2562, mode: `MaxEncodedLen`)
/// The range of component `q` is `[1, 1024]`.
fn create_memberships(q: u16, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 172_690_000 picoseconds.
Weight::from_parts(178_773_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(14))
// Measured: `368`
// Estimated: `3547 + q * (3334 ±0)`
// Minimum execution time: 87_026_000 picoseconds.
Weight::from_parts(110_670_000, 0)
.saturating_add(Weight::from_parts(0, 3547))
// Standard Error: 331_618
.saturating_add(Weight::from_parts(83_810_638, 0).saturating_mul(q.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(q.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(q.into())))
.saturating_add(Weight::from_parts(0, 3334).saturating_mul(q.into()))
}
}
Loading

0 comments on commit e4bdc26

Please sign in to comment.