Skip to content

Commit

Permalink
Benchmarking: Calculate weights for 3ade16a (#410)
Browse files Browse the repository at this point in the history
* [ci] calculate weights

* change(communities-manager): test extrinsic weights

* change(pallet-communities): test extrinsic weights

* fix(pallet-communities-manager): restore q counter in weights as u32

---------

Co-authored-by: pandres95 <[email protected]>
Co-authored-by: Pablo Andrés Dorado Suárez <[email protected]>
  • Loading branch information
3 people authored May 31, 2024
1 parent 3ade16a commit 6f3abd6
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion pallets/communities-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub mod pallet {
Ok(())
}

#[pallet::weight(<T as Config>::WeightInfo::create_memberships(*amount))]
#[pallet::weight(<T as Config>::WeightInfo::create_memberships((*amount).into()))]
#[pallet::call_index(1)]
pub fn create_memberships(
origin: OriginFor<T>,
Expand Down
4 changes: 2 additions & 2 deletions pallets/communities-manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn weights() {
let calls = vec![
("register", SubstrateWeight::<Test>::register()),
(
"create_memberships(100)",
SubstrateWeight::<Test>::create_memberships(100),
"create_memberships(1024)",
SubstrateWeight::<Test>::create_memberships(1024),
),
];

Expand Down
42 changes: 21 additions & 21 deletions pallets/communities-manager/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ use core::marker::PhantomData;
/// Weight functions needed for pallet_communities.
pub trait WeightInfo {
fn register() -> Weight;
fn create_memberships(q: u16, ) -> Weight;
fn create_memberships(q: u32, ) -> Weight;
}

/// Weights for pallet_communities using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Storage: `Communities::Info` (r:1 w:1)
/// Proof: `Communities::Info` (`max_values`: None, `max_size`: Some(19), added: 2494, mode: `MaxEncodedLen`)
/// Storage: `Communities::CommunityIdFor` (r:1 w:1)
/// Proof: `Communities::CommunityIdFor` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Collection` (r:1 w:1)
Expand All @@ -28,8 +30,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `KreivoCollective::Members` (`max_values`: None, `max_size`: Some(42), added: 2517, mode: `MaxEncodedLen`)
/// Storage: `KreivoCollective::MemberCount` (r:1 w:1)
/// Proof: `KreivoCollective::MemberCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Communities::CommunityIdFor` (r:0 w:1)
/// Proof: `Communities::CommunityIdFor` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
/// Storage: `KreivoCollective::IndexToId` (r:0 w:1)
/// Proof: `KreivoCollective::IndexToId` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`)
/// Storage: `KreivoCollective::IdToIndex` (r:0 w:1)
Expand All @@ -46,10 +46,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 115_705_000 picoseconds.
Weight::from_parts(140_658_000, 0)
// Minimum execution time: 172_021_000 picoseconds.
Weight::from_parts(181_851_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(14))
}
/// Storage: `CommunityMemberships::Item` (r:1023 w:1023)
Expand All @@ -65,15 +65,15 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// 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 {
fn create_memberships(q: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `368`
// Estimated: `3547 + q * (3334 ±0)`
// Minimum execution time: 87_026_000 picoseconds.
Weight::from_parts(110_670_000, 0)
// Minimum execution time: 125_757_000 picoseconds.
Weight::from_parts(127_470_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()))
// Standard Error: 322_917
.saturating_add(Weight::from_parts(87_141_783, 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))
Expand All @@ -85,6 +85,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
impl WeightInfo for () {
/// Storage: `Communities::Info` (r:1 w:1)
/// Proof: `Communities::Info` (`max_values`: None, `max_size`: Some(19), added: 2494, mode: `MaxEncodedLen`)
/// Storage: `Communities::CommunityIdFor` (r:1 w:1)
/// Proof: `Communities::CommunityIdFor` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `CommunityMemberships::Collection` (r:1 w:1)
Expand All @@ -97,8 +99,6 @@ impl WeightInfo for () {
/// Proof: `KreivoCollective::Members` (`max_values`: None, `max_size`: Some(42), added: 2517, mode: `MaxEncodedLen`)
/// Storage: `KreivoCollective::MemberCount` (r:1 w:1)
/// Proof: `KreivoCollective::MemberCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Communities::CommunityIdFor` (r:0 w:1)
/// Proof: `Communities::CommunityIdFor` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`)
/// Storage: `KreivoCollective::IndexToId` (r:0 w:1)
/// Proof: `KreivoCollective::IndexToId` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`)
/// Storage: `KreivoCollective::IdToIndex` (r:0 w:1)
Expand All @@ -115,10 +115,10 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `278`
// Estimated: `132561`
// Minimum execution time: 115_705_000 picoseconds.
Weight::from_parts(140_658_000, 0)
// Minimum execution time: 172_021_000 picoseconds.
Weight::from_parts(181_851_000, 0)
.saturating_add(Weight::from_parts(0, 132561))
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().reads(8))
.saturating_add(RocksDbWeight::get().writes(14))
}
/// Storage: `CommunityMemberships::Item` (r:1023 w:1023)
Expand All @@ -134,15 +134,15 @@ impl WeightInfo for () {
/// 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 {
fn create_memberships(q: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `368`
// Estimated: `3547 + q * (3334 ±0)`
// Minimum execution time: 87_026_000 picoseconds.
Weight::from_parts(110_670_000, 0)
// Minimum execution time: 125_757_000 picoseconds.
Weight::from_parts(127_470_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()))
// Standard Error: 322_917
.saturating_add(Weight::from_parts(87_141_783, 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))
Expand Down
88 changes: 44 additions & 44 deletions pallets/communities/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -73,8 +73,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -87,8 +87,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -119,8 +119,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -149,8 +149,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -165,8 +165,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -181,8 +181,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -209,8 +209,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -229,8 +229,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -249,8 +249,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 @@ -261,8 +261,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<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 All @@ -280,8 +280,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(3))
Expand All @@ -294,8 +294,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(2))
Expand All @@ -308,8 +308,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
Expand Down Expand Up @@ -340,8 +340,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(13))
.saturating_add(RocksDbWeight::get().writes(13))
Expand Down Expand Up @@ -370,8 +370,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(10))
.saturating_add(RocksDbWeight::get().writes(10))
Expand All @@ -386,8 +386,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
Expand All @@ -402,8 +402,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
Expand All @@ -430,8 +430,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(10))
.saturating_add(RocksDbWeight::get().writes(6))
Expand All @@ -450,8 +450,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(2))
Expand All @@ -470,8 +470,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().writes(3))
Expand All @@ -482,8 +482,8 @@ impl WeightInfo for () {
// 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(RocksDbWeight::get().reads(1))
}
Expand Down
Loading

0 comments on commit 6f3abd6

Please sign in to comment.