From a625bf49d8620d03982fe7643bedaae84d6d3ace Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Thu, 21 Mar 2024 14:12:11 +0100 Subject: [PATCH] fix benchmarks --- pallets/certification/src/benchmarking.rs | 16 ---- pallets/identity/src/benchmarking.rs | 32 ------- .../src/weights/pallet_certification.rs | 52 ++++------- runtime/common/src/weights/pallet_identity.rs | 88 ++++++++----------- 4 files changed, 54 insertions(+), 134 deletions(-) diff --git a/pallets/certification/src/benchmarking.rs b/pallets/certification/src/benchmarking.rs index 3e47370a0..1fa4b0bfb 100644 --- a/pallets/certification/src/benchmarking.rs +++ b/pallets/certification/src/benchmarking.rs @@ -47,22 +47,6 @@ mod benchmarks { Ok(()) } - #[benchmark] - fn do_add_cert_checked() -> Result<(), BenchmarkError> { - let issuer: T::IdtyIndex = 1.into(); - let receiver: T::IdtyIndex = 2.into(); - Pallet::<T>::del_cert(RawOrigin::Root.into(), issuer, receiver)?; - frame_system::pallet::Pallet::<T>::set_block_number(T::CertPeriod::get()); - - #[block] - { - Pallet::<T>::do_add_cert_checked(issuer, receiver, true)?; - } - - assert_has_event::<T>(Event::<T>::CertAdded { issuer, receiver }.into()); - Ok(()) - } - #[benchmark] fn add_cert() -> Result<(), BenchmarkError> { let issuer: T::IdtyIndex = 1.into(); diff --git a/pallets/identity/src/benchmarking.rs b/pallets/identity/src/benchmarking.rs index f693a5de7..734707ae0 100644 --- a/pallets/identity/src/benchmarking.rs +++ b/pallets/identity/src/benchmarking.rs @@ -451,38 +451,6 @@ mod benchmarks { } } - #[benchmark] - fn membership_added() -> Result<(), BenchmarkError> { - let caller: T::AccountId = Identities::<T>::get(T::IdtyIndex::from(1u32)) - .unwrap() - .owner_key; - let caller_origin: <T as frame_system::Config>::RuntimeOrigin = - RawOrigin::Signed(caller.clone()).into(); - let owner_key: T::AccountId = account("new_identity", 2, 1); - let owner_key_origin: <T as frame_system::Config>::RuntimeOrigin = - RawOrigin::Signed(owner_key.clone()).into(); - Pallet::<T>::create_identity(caller_origin.clone(), owner_key.clone())?; - let name = IdtyName("new_identity".into()); - Pallet::<T>::confirm_identity(owner_key_origin.clone(), name.clone())?; - let idty_index = IdentityIndexOf::<T>::get(&owner_key).unwrap(); - assert_ne!( - Identities::<T>::get(idty_index).unwrap().status, - IdtyStatus::Member - ); - - #[block] - { - Pallet::<T>::membership_added(idty_index); - } - - assert_has_event::<T>(Event::<T>::IdtyValidated { idty_index }.into()); - assert_eq!( - Identities::<T>::get(idty_index).unwrap().status, - IdtyStatus::Member - ); - Ok(()) - } - #[benchmark] fn membership_removed() -> Result<(), BenchmarkError> { let key: T::AccountId = account("new_identity", 2, 1); diff --git a/runtime/common/src/weights/pallet_certification.rs b/runtime/common/src/weights/pallet_certification.rs index 68a96c39e..cc008e2c1 100644 --- a/runtime/common/src/weights/pallet_certification.rs +++ b/runtime/common/src/weights/pallet_certification.rs @@ -29,7 +29,7 @@ // --chain=dev // --steps=50 // --repeat=20 -// --pallet=* +// --pallet=pallet-certification // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 @@ -47,24 +47,6 @@ use core::marker::PhantomData; /// Weight functions for `pallet_certification`. pub struct WeightInfo<T>(PhantomData<T>); impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> { - /// Storage: `Certification::StorageIdtyCertMeta` (r:2 w:2) - /// Proof: `Certification::StorageIdtyCertMeta` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Parameters::ParametersStorage` (r:1 w:0) - /// Proof: `Parameters::ParametersStorage` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Certification::CertsRemovableOn` (r:1 w:1) - /// Proof: `Certification::CertsRemovableOn` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Certification::CertsByReceiver` (r:1 w:1) - /// Proof: `Certification::CertsByReceiver` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn do_add_cert_checked() -> Weight { - // Proof Size summary in bytes: - // Measured: `465` - // Estimated: `6405` - // Minimum execution time: 18_760_000 picoseconds. - Weight::from_parts(19_560_000, 0) - .saturating_add(Weight::from_parts(0, 6405)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } /// Storage: `Identity::IdentityIndexOf` (r:1 w:0) /// Proof: `Identity::IdentityIndexOf` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Certification::StorageIdtyCertMeta` (r:2 w:2) @@ -81,8 +63,8 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `956` // Estimated: `6896` - // Minimum execution time: 30_500_000 picoseconds. - Weight::from_parts(36_702_000, 0) + // Minimum execution time: 30_521_000 picoseconds. + Weight::from_parts(31_388_000, 0) .saturating_add(Weight::from_parts(0, 6896)) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) @@ -103,8 +85,8 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `980` // Estimated: `6920` - // Minimum execution time: 29_705_000 picoseconds. - Weight::from_parts(31_117_000, 0) + // Minimum execution time: 28_768_000 picoseconds. + Weight::from_parts(29_974_000, 0) .saturating_add(Weight::from_parts(0, 6920)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) @@ -119,8 +101,8 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `444` // Estimated: `6384` - // Minimum execution time: 17_203_000 picoseconds. - Weight::from_parts(17_957_000, 0) + // Minimum execution time: 17_405_000 picoseconds. + Weight::from_parts(23_829_000, 0) .saturating_add(Weight::from_parts(0, 6384)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) @@ -138,11 +120,11 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `546 + i * (35 ±0)` // Estimated: `4017 + i * (2511 ±0)` - // Minimum execution time: 24_706_000 picoseconds. - Weight::from_parts(25_381_000, 0) + // Minimum execution time: 24_543_000 picoseconds. + Weight::from_parts(24_900_000, 0) .saturating_add(Weight::from_parts(0, 4017)) - // Standard Error: 20_786 - .saturating_add(Weight::from_parts(8_520_837, 0).saturating_mul(i.into())) + // Standard Error: 50_900 + .saturating_add(Weight::from_parts(9_036_718, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -155,8 +137,8 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `139` // Estimated: `3604` - // Minimum execution time: 2_358_000 picoseconds. - Weight::from_parts(2_635_000, 0) + // Minimum execution time: 2_295_000 picoseconds. + Weight::from_parts(2_512_000, 0) .saturating_add(Weight::from_parts(0, 3604)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -166,8 +148,8 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `237` // Estimated: `3702` - // Minimum execution time: 3_428_000 picoseconds. - Weight::from_parts(3_646_000, 0) + // Minimum execution time: 3_435_000 picoseconds. + Weight::from_parts(3_720_000, 0) .saturating_add(Weight::from_parts(0, 3702)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -184,8 +166,8 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T> // Proof Size summary in bytes: // Measured: `660` // Estimated: `6600` - // Minimum execution time: 18_892_000 picoseconds. - Weight::from_parts(19_928_000, 0) + // Minimum execution time: 19_827_000 picoseconds. + Weight::from_parts(20_470_000, 0) .saturating_add(Weight::from_parts(0, 6600)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) diff --git a/runtime/common/src/weights/pallet_identity.rs b/runtime/common/src/weights/pallet_identity.rs index bae617f2a..593de4c76 100644 --- a/runtime/common/src/weights/pallet_identity.rs +++ b/runtime/common/src/weights/pallet_identity.rs @@ -29,7 +29,7 @@ // --chain=dev // --steps=50 // --repeat=20 -// --pallet=* +// --pallet=pallet-identity // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 @@ -73,8 +73,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `1022` // Estimated: `6962` - // Minimum execution time: 59_348_000 picoseconds. - Weight::from_parts(61_709_000, 0) + // Minimum execution time: 60_458_000 picoseconds. + Weight::from_parts(62_727_000, 0) .saturating_add(Weight::from_parts(0, 6962)) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) @@ -91,8 +91,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `698` // Estimated: `6638` - // Minimum execution time: 26_586_000 picoseconds. - Weight::from_parts(27_590_000, 0) + // Minimum execution time: 28_622_000 picoseconds. + Weight::from_parts(29_508_000, 0) .saturating_add(Weight::from_parts(0, 6638)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) @@ -109,8 +109,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `727` // Estimated: `6667` - // Minimum execution time: 72_587_000 picoseconds. - Weight::from_parts(75_938_000, 0) + // Minimum execution time: 73_352_000 picoseconds. + Weight::from_parts(75_459_000, 0) .saturating_add(Weight::from_parts(0, 6667)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(5)) @@ -129,8 +129,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `664` // Estimated: `6604` - // Minimum execution time: 62_852_000 picoseconds. - Weight::from_parts(64_875_000, 0) + // Minimum execution time: 63_115_000 picoseconds. + Weight::from_parts(64_603_000, 0) .saturating_add(Weight::from_parts(0, 6604)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) @@ -142,11 +142,11 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_611_000 picoseconds. - Weight::from_parts(3_752_000, 0) + // Minimum execution time: 3_664_000 picoseconds. + Weight::from_parts(3_883_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_131 - .saturating_add(Weight::from_parts(1_209_872, 0).saturating_mul(i.into())) + // Standard Error: 863 + .saturating_add(Weight::from_parts(1_217_853, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } @@ -156,8 +156,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `104` // Estimated: `3558` - // Minimum execution time: 6_260_000 picoseconds. - Weight::from_parts(6_846_000, 0) + // Minimum execution time: 6_168_000 picoseconds. + Weight::from_parts(6_607_000, 0) .saturating_add(Weight::from_parts(0, 3558)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -172,8 +172,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `403` // Estimated: `3868` - // Minimum execution time: 50_110_000 picoseconds. - Weight::from_parts(51_225_000, 0) + // Minimum execution time: 49_185_000 picoseconds. + Weight::from_parts(50_359_000, 0) .saturating_add(Weight::from_parts(0, 3868)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) @@ -182,8 +182,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 140_000 picoseconds. - Weight::from_parts(164_000, 0) + // Minimum execution time: 120_000 picoseconds. + Weight::from_parts(135_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// Storage: `Identity::Identities` (r:1 w:0) @@ -192,8 +192,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `302` // Estimated: `3767` - // Minimum execution time: 3_599_000 picoseconds. - Weight::from_parts(3_798_000, 0) + // Minimum execution time: 3_420_000 picoseconds. + Weight::from_parts(3_635_000, 0) .saturating_add(Weight::from_parts(0, 3767)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -231,8 +231,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `1555` // Estimated: `9970` - // Minimum execution time: 85_181_000 picoseconds. - Weight::from_parts(88_169_000, 0) + // Minimum execution time: 80_698_000 picoseconds. + Weight::from_parts(84_553_000, 0) .saturating_add(Weight::from_parts(0, 9970)) .saturating_add(T::DbWeight::get().reads(16)) .saturating_add(T::DbWeight::get().writes(20)) @@ -243,8 +243,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `302` // Estimated: `3767` - // Minimum execution time: 3_362_000 picoseconds. - Weight::from_parts(3_643_000, 0) + // Minimum execution time: 3_452_000 picoseconds. + Weight::from_parts(3_571_000, 0) .saturating_add(Weight::from_parts(0, 3767)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -288,8 +288,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `1990` // Estimated: `12880` - // Minimum execution time: 117_356_000 picoseconds. - Weight::from_parts(120_866_000, 0) + // Minimum execution time: 111_633_000 picoseconds. + Weight::from_parts(115_818_000, 0) .saturating_add(Weight::from_parts(0, 12880)) .saturating_add(T::DbWeight::get().reads(21)) .saturating_add(T::DbWeight::get().writes(26)) @@ -334,36 +334,22 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `1999` // Estimated: `12889` - // Minimum execution time: 107_292_000 picoseconds. - Weight::from_parts(112_833_000, 0) + // Minimum execution time: 108_432_000 picoseconds. + Weight::from_parts(113_373_000, 0) .saturating_add(Weight::from_parts(0, 12889)) .saturating_add(T::DbWeight::get().reads(22)) .saturating_add(T::DbWeight::get().writes(25)) } /// Storage: `Identity::Identities` (r:1 w:1) /// Proof: `Identity::Identities` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Identity::IdentityChangeSchedule` (r:1 w:1) - /// Proof: `Identity::IdentityChangeSchedule` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn membership_added() -> Weight { - // Proof Size summary in bytes: - // Measured: `407` - // Estimated: `3872` - // Minimum execution time: 13_963_000 picoseconds. - Weight::from_parts(14_895_000, 0) - .saturating_add(Weight::from_parts(0, 3872)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `Identity::Identities` (r:1 w:1) - /// Proof: `Identity::Identities` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Identity::IdentityChangeSchedule` (r:2 w:2) /// Proof: `Identity::IdentityChangeSchedule` (`max_values`: None, `max_size`: None, mode: `Measured`) fn membership_removed() -> Weight { // Proof Size summary in bytes: // Measured: `407` // Estimated: `6347` - // Minimum execution time: 14_498_000 picoseconds. - Weight::from_parts(15_247_000, 0) + // Minimum execution time: 13_935_000 picoseconds. + Weight::from_parts(14_601_000, 0) .saturating_add(Weight::from_parts(0, 6347)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) @@ -374,8 +360,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `157` // Estimated: `3622` - // Minimum execution time: 2_757_000 picoseconds. - Weight::from_parts(2_911_000, 0) + // Minimum execution time: 2_501_000 picoseconds. + Weight::from_parts(2_758_000, 0) .saturating_add(Weight::from_parts(0, 3622)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -387,8 +373,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `327` // Estimated: `3792` - // Minimum execution time: 6_084_000 picoseconds. - Weight::from_parts(6_319_000, 0) + // Minimum execution time: 5_740_000 picoseconds. + Weight::from_parts(6_198_000, 0) .saturating_add(Weight::from_parts(0, 3792)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -413,8 +399,8 @@ impl<T: frame_system::Config> pallet_identity::WeightInfo for WeightInfo<T> { // Proof Size summary in bytes: // Measured: `851` // Estimated: `4316` - // Minimum execution time: 30_790_000 picoseconds. - Weight::from_parts(31_664_000, 0) + // Minimum execution time: 30_080_000 picoseconds. + Weight::from_parts(31_099_000, 0) .saturating_add(Weight::from_parts(0, 4316)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(7)) -- GitLab