git.delta.rocks / unique-network / refs/commits / 447167e12c6d

difftreelog

feat(rmrk) benchmark new mint_nft

Daniel Shiposha2022-06-14parent: #1946e45.patch.diff
in: master

3 files changed

modifiedpallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth
53 }53 }
54}54}
55
56fn create_max_resource_types_array<S: Get<u32>>(num: usize) -> BoundedVec<RmrkResourceTypes, S> {
57 vec![RmrkResourceTypes::Composable(create_composable_resource()); num].try_into().expect("num <= S")
58}
5559
56fn create_max_collection<T: Config>(owner: &T::AccountId) -> DispatchResult {60fn create_max_collection<T: Config>(owner: &T::AccountId) -> DispatchResult {
57 <T as pallet_common::Config>::Currency::deposit_creating(61 <T as pallet_common::Config>::Currency::deposit_creating(
71 )75 )
72}76}
7377
74fn create_max_nft<T: Config>(78fn create_nft<T: Config>(
75 owner: &T::AccountId,79 owner: &T::AccountId,
76 collection_id: RmrkCollectionId,80 collection_id: RmrkCollectionId,
77) -> DispatchResult {81) -> DispatchResult {
88 royalty_amount,92 royalty_amount,
89 metadata,93 metadata,
90 transferable,94 transferable,
95 None
91 )96 )
92}97}
9398
109 }114 }
110115
111 fn build<T: Config>(&mut self, owner: &T::AccountId) -> Result<RmrkNftId, DispatchError> {116 fn build<T: Config>(&mut self, owner: &T::AccountId) -> Result<RmrkNftId, DispatchError> {
112 create_max_nft::<T>(owner, self.collection_id)?;117 create_nft::<T>(owner, self.collection_id)?;
113 self.current_nft_id += 1;118 self.current_nft_id += 1;
114119
115 Ok(self.current_nft_id)120 Ok(self.current_nft_id)
213 }: _(RawOrigin::Signed(caller), collection_id)218 }: _(RawOrigin::Signed(caller), collection_id)
214219
215 mint_nft {220 mint_nft {
221 let b in 0..100;
222
216 let caller: T::AccountId = account("caller", 0, SEED);223 let caller: T::AccountId = account("caller", 0, SEED);
224 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
217225
218 create_max_collection::<T>(&caller)?;226 create_max_collection::<T>(&caller)?;
219 let collection_id = 0;227 let collection_id = 0;
230 royalty_recipient,238 royalty_recipient,
231 royalty_amount,239 royalty_amount,
232 metadata,240 metadata,
233 transferable241 transferable,
242 Some(create_max_resource_types_array(b as usize))
234 )243 )
235244
236 burn_nft {245 burn_nft {
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -344,7 +344,7 @@
 		/// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash
 		/// - `transferable`: Ability to transfer this NFT
 		#[transactional]
-		#[pallet::weight(<SelfWeightOf<T>>::mint_nft())]
+		#[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]
 		pub fn mint_nft(
 			origin: OriginFor<T>,
 			owner: T::AccountId,
modifiedpallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/weights.rs
+++ b/pallets/proxy-rmrk-core/src/weights.rs
@@ -3,7 +3,7 @@
 //! Autogenerated weights for pallet_proxy_rmrk_core
 //!
 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2022-06-10, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`
 //! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
 
 // Executed Command:
@@ -37,7 +37,7 @@
 	fn destroy_collection() -> Weight;
 	fn change_collection_issuer() -> Weight;
 	fn lock_collection() -> Weight;
-	fn mint_nft() -> Weight;
+	fn mint_nft(b: u32, ) -> Weight;
 	fn burn_nft(b: u32, ) -> Weight;
 	fn send() -> Weight;
 	fn accept_nft() -> Weight;
@@ -64,7 +64,7 @@
 	// Storage: Common CollectionById (r:0 w:1)
 	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
 	fn create_collection() -> Weight {
-		(40_837_000 as Weight)
+		(41_277_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(8 as Weight))
 	}
@@ -77,7 +77,7 @@
 	// Storage: Nonfungible TokensBurnt (r:0 w:1)
 	// Storage: Common AdminAmount (r:0 w:1)
 	fn destroy_collection() -> Weight {
-		(44_544_000 as Weight)
+		(43_371_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
@@ -85,7 +85,7 @@
 	// Storage: Common CollectionById (r:1 w:1)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	fn change_collection_issuer() -> Weight {
-		(22_151_000 as Weight)
+		(21_891_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(3 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -95,7 +95,7 @@
 	// Storage: Nonfungible TokensMinted (r:1 w:0)
 	// Storage: Nonfungible TokensBurnt (r:1 w:0)
 	fn lock_collection() -> Weight {
-		(23_766_000 as Weight)
+		(23_144_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(5 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -107,10 +107,18 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
-	fn mint_nft() -> Weight {
-		(40_237_000 as Weight)
-			.saturating_add(T::DbWeight::get().reads(6 as Weight))
-			.saturating_add(T::DbWeight::get().writes(5 as Weight))
+	// Storage: Common CreatedCollectionCount (r:1 w:1)
+	// Storage: Common DestroyedCollectionCount (r:1 w:0)
+	// Storage: System Account (r:2 w:2)
+	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	fn mint_nft(b: u32, ) -> Weight {
+		(68_329_000 as Weight)
+			// Standard Error: 3_000
+			.saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(T::DbWeight::get().reads(12 as Weight))
+			.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
+			.saturating_add(T::DbWeight::get().writes(12 as Weight))
+			.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
@@ -124,8 +132,8 @@
 	// Storage: Nonfungible TokenProperties (r:0 w:1)
 	fn burn_nft(b: u32, ) -> Weight {
 		(0 as Weight)
-			// Standard Error: 1_023_000
-			.saturating_add((318_424_000 as Weight).saturating_mul(b as Weight))
+			// Standard Error: 959_000
+			.saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
@@ -141,7 +149,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn send() -> Weight {
-		(71_055_000 as Weight)
+		(71_405_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(12 as Weight))
 			.saturating_add(T::DbWeight::get().writes(6 as Weight))
 	}
@@ -155,7 +163,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn accept_nft() -> Weight {
-		(79_098_000 as Weight)
+		(79_159_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(15 as Weight))
 			.saturating_add(T::DbWeight::get().writes(7 as Weight))
 	}
@@ -170,7 +178,7 @@
 	// Storage: Nonfungible Allowance (r:5 w:0)
 	// Storage: Nonfungible Owned (r:0 w:5)
 	fn reject_nft() -> Weight {
-		(237_777_000 as Weight)
+		(238_179_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(29 as Weight))
 			.saturating_add(T::DbWeight::get().writes(25 as Weight))
 	}
@@ -180,7 +188,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_property() -> Weight {
-		(47_359_000 as Weight)
+		(47_770_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -190,7 +198,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_priority() -> Weight {
-		(46_537_000 as Weight)
+		(46_679_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(9 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -207,7 +215,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_basic_resource() -> Weight {
-		(100_939_000 as Weight)
+		(100_770_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(12 as Weight))
 	}
@@ -224,7 +232,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_composable_resource() -> Weight {
-		(101_821_000 as Weight)
+		(101_791_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(12 as Weight))
 	}
@@ -241,7 +249,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_slot_resource() -> Weight {
-		(100_880_000 as Weight)
+		(101_610_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(12 as Weight))
 	}
@@ -256,7 +264,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn remove_resource() -> Weight {
-		(79_831_000 as Weight)
+		(80_571_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(16 as Weight))
 			.saturating_add(T::DbWeight::get().writes(5 as Weight))
 	}
@@ -266,7 +274,7 @@
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	// Storage: Nonfungible TokenProperties (r:2 w:1)
 	fn accept_resource() -> Weight {
-		(54_573_000 as Weight)
+		(54_733_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(10 as Weight))
 			.saturating_add(T::DbWeight::get().writes(1 as Weight))
 	}
@@ -281,7 +289,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn accept_resource_removal() -> Weight {
-		(83_426_000 as Weight)
+		(84_138_000 as Weight)
 			.saturating_add(T::DbWeight::get().reads(17 as Weight))
 			.saturating_add(T::DbWeight::get().writes(5 as Weight))
 	}
@@ -298,7 +306,7 @@
 	// Storage: Common CollectionById (r:0 w:1)
 	// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
 	fn create_collection() -> Weight {
-		(40_837_000 as Weight)
+		(41_277_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(8 as Weight))
 	}
@@ -311,7 +319,7 @@
 	// Storage: Nonfungible TokensBurnt (r:0 w:1)
 	// Storage: Common AdminAmount (r:0 w:1)
 	fn destroy_collection() -> Weight {
-		(44_544_000 as Weight)
+		(43_371_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
@@ -319,7 +327,7 @@
 	// Storage: Common CollectionById (r:1 w:1)
 	// Storage: Common CollectionProperties (r:1 w:0)
 	fn change_collection_issuer() -> Weight {
-		(22_151_000 as Weight)
+		(21_891_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(3 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -329,7 +337,7 @@
 	// Storage: Nonfungible TokensMinted (r:1 w:0)
 	// Storage: Nonfungible TokensBurnt (r:1 w:0)
 	fn lock_collection() -> Weight {
-		(23_766_000 as Weight)
+		(23_144_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(5 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -341,10 +349,18 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:1)
-	fn mint_nft() -> Weight {
-		(40_237_000 as Weight)
-			.saturating_add(RocksDbWeight::get().reads(6 as Weight))
-			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
+	// Storage: Common CreatedCollectionCount (r:1 w:1)
+	// Storage: Common DestroyedCollectionCount (r:1 w:0)
+	// Storage: System Account (r:2 w:2)
+	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
+	fn mint_nft(b: u32, ) -> Weight {
+		(68_329_000 as Weight)
+			// Standard Error: 3_000
+			.saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))
+			.saturating_add(RocksDbWeight::get().reads(12 as Weight))
+			.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
+			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
+			.saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
 	}
 	// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
 	// Storage: Common CollectionProperties (r:1 w:0)
@@ -358,8 +374,8 @@
 	// Storage: Nonfungible TokenProperties (r:0 w:1)
 	fn burn_nft(b: u32, ) -> Weight {
 		(0 as Weight)
-			// Standard Error: 1_023_000
-			.saturating_add((318_424_000 as Weight).saturating_mul(b as Weight))
+			// Standard Error: 959_000
+			.saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
@@ -375,7 +391,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn send() -> Weight {
-		(71_055_000 as Weight)
+		(71_405_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(12 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(6 as Weight))
 	}
@@ -389,7 +405,7 @@
 	// Storage: Nonfungible TokenChildren (r:0 w:1)
 	// Storage: Nonfungible Owned (r:0 w:2)
 	fn accept_nft() -> Weight {
-		(79_098_000 as Weight)
+		(79_159_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(15 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(7 as Weight))
 	}
@@ -404,7 +420,7 @@
 	// Storage: Nonfungible Allowance (r:5 w:0)
 	// Storage: Nonfungible Owned (r:0 w:5)
 	fn reject_nft() -> Weight {
-		(237_777_000 as Weight)
+		(238_179_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(29 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(25 as Weight))
 	}
@@ -414,7 +430,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_property() -> Weight {
-		(47_359_000 as Weight)
+		(47_770_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -424,7 +440,7 @@
 	// Storage: Nonfungible TokenProperties (r:1 w:1)
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	fn set_priority() -> Weight {
-		(46_537_000 as Weight)
+		(46_679_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(9 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -441,7 +457,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_basic_resource() -> Weight {
-		(100_939_000 as Weight)
+		(100_770_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
 	}
@@ -458,7 +474,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_composable_resource() -> Weight {
-		(101_821_000 as Weight)
+		(101_791_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
 	}
@@ -475,7 +491,7 @@
 	// Storage: Nonfungible Owned (r:0 w:1)
 	// Storage: Common CollectionPropertyPermissions (r:0 w:1)
 	fn add_slot_resource() -> Weight {
-		(100_880_000 as Weight)
+		(101_610_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(12 as Weight))
 	}
@@ -490,7 +506,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn remove_resource() -> Weight {
-		(79_831_000 as Weight)
+		(80_571_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(16 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
 	}
@@ -500,7 +516,7 @@
 	// Storage: Nonfungible TokenData (r:5 w:0)
 	// Storage: Nonfungible TokenProperties (r:2 w:1)
 	fn accept_resource() -> Weight {
-		(54_573_000 as Weight)
+		(54_733_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(10 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(1 as Weight))
 	}
@@ -515,7 +531,7 @@
 	// Storage: Nonfungible Allowance (r:1 w:0)
 	// Storage: Nonfungible Owned (r:0 w:1)
 	fn accept_resource_removal() -> Weight {
-		(83_426_000 as Weight)
+		(84_138_000 as Weight)
 			.saturating_add(RocksDbWeight::get().reads(17 as Weight))
 			.saturating_add(RocksDbWeight::get().writes(5 as Weight))
 	}