From 87c401906db8aabad792c13bafc4e65fe11e62da Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Tue, 31 Aug 2021 09:37:56 +0000 Subject: [PATCH] feat: bench bulk mints --- --- a/pallets/nft/src/benchmarking.rs +++ b/pallets/nft/src/benchmarking.rs @@ -162,6 +162,16 @@ }); }: create_item(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(caller.clone()), data) + create_multiple_items_nft { + // TODO: Take item data size into account. As create_item_nft bench shows, this parameter has no effect on execution time, + // but it may if we increase CUSTOM_DATA_LIMIT + let b in 1..1000; + + let caller: T::AccountId = account("caller", 0, SEED); + let collection = create_nft_collection::(caller.clone())?; + let data = (0..b).map(|_| default_nft_data()).collect(); + }: create_multiple_items(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(caller.clone()), data) + // fungible item create_item_fungible { let caller: T::AccountId = account("caller", 0, SEED); @@ -171,6 +181,14 @@ }); }: create_item(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(caller.clone()), data) + create_multiple_items_fungible { + let b in 1..1000; + + let caller: T::AccountId = account("caller", 0, SEED); + let collection = create_fungible_collection::(caller.clone())?; + let data = (0..b).map(|_| default_fungible_data()).collect(); + }: create_multiple_items(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(caller.clone()), data) + // refungible item create_item_refungible { let b in 0..(CUSTOM_DATA_LIMIT * 2); @@ -184,6 +202,16 @@ }); }: create_item(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(caller.clone()), data) + create_multiple_items_refungible { + // TODO: Take item data size into account. As create_item_nft bench shows, this parameter has no effect on execution time, + // but it may if we increase CUSTOM_DATA_LIMIT + let b in 1..1000; + + let caller: T::AccountId = account("caller", 0, SEED); + let collection = create_refungible_collection::(caller.clone())?; + let data = (0..b).map(|_| default_re_fungible_data()).collect(); + }: create_multiple_items(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(caller.clone()), data) + burn_item_nft { let caller: T::AccountId = account("caller", 0, SEED); let collection = create_nft_collection::(caller.clone())?; @@ -215,6 +243,11 @@ >::create_item(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(caller.clone()), data)?; }: transfer(RawOrigin::Signed(caller.clone()), T::CrossAccountId::from_sub(recipient.clone()), collection, 1, 1) + set_transfers_enabled_flag { + let caller: T::AccountId = account("caller", 0, SEED); + let collection = create_nft_collection::(caller.clone())?; + }: _(RawOrigin::Signed(caller.clone()), collection, false) + approve_nft { let caller: T::AccountId = account("caller", 0, SEED); let collection = create_nft_collection::(caller.clone())?; --- a/pallets/nft/src/weights.rs +++ b/pallets/nft/src/weights.rs @@ -3,7 +3,7 @@ //! Autogenerated weights for pallet_nft //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-08-30, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-08-31, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128 // Executed Command: @@ -44,12 +44,16 @@ fn confirm_sponsorship() -> Weight; fn remove_collection_sponsor() -> Weight; fn create_item_nft(b: u32, ) -> Weight; + fn create_multiple_items_nft(b: u32, ) -> Weight; fn create_item_fungible() -> Weight; + fn create_multiple_items_fungible(b: u32, ) -> Weight; fn create_item_refungible(b: u32, ) -> Weight; + fn create_multiple_items_refungible(b: u32, ) -> Weight; fn burn_item_nft() -> Weight; fn transfer_nft() -> Weight; fn transfer_fungible() -> Weight; fn transfer_refungible() -> Weight; + fn set_transfers_enabled_flag() -> Weight; fn approve_nft() -> Weight; fn transfer_from_nft() -> Weight; fn transfer_from_fungible() -> Weight; @@ -130,8 +134,23 @@ .saturating_add(T::DbWeight::get().reads(11 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } + fn create_multiple_items_nft(b: u32, ) -> Weight { + (336_830_000 as Weight) + // Standard Error: 42_000 + .saturating_add((11_627_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(T::DbWeight::get().reads(11 as Weight)) + .saturating_add(T::DbWeight::get().writes(7 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + } fn create_item_fungible() -> Weight { - (22_331_000 as Weight) + (24_123_000 as Weight) + .saturating_add(T::DbWeight::get().reads(9 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } + fn create_multiple_items_fungible(b: u32, ) -> Weight { + (48_227_000 as Weight) + // Standard Error: 13_000 + .saturating_add((2_918_000 as Weight).saturating_mul(b as Weight)) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -140,6 +159,14 @@ .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(7 as Weight)) } + fn create_multiple_items_refungible(b: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 16_000 + .saturating_add((8_374_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(T::DbWeight::get().reads(9 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + } fn burn_item_nft() -> Weight { (32_237_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) @@ -160,6 +187,11 @@ .saturating_add(T::DbWeight::get().reads(10 as Weight)) .saturating_add(T::DbWeight::get().writes(7 as Weight)) } + fn set_transfers_enabled_flag() -> Weight { + (6_376_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } fn approve_nft() -> Weight { (169_825_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) @@ -274,13 +306,30 @@ .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } - fn create_item_nft(_b: u32, ) -> Weight { - (167_909_000 as Weight) + fn create_item_nft(b: u32, ) -> Weight { + (167_180_000 as Weight) + // Standard Error: 1_000 + .saturating_add((10_000 as Weight).saturating_mul(b as Weight)) .saturating_add(RocksDbWeight::get().reads(11 as Weight)) .saturating_add(RocksDbWeight::get().writes(8 as Weight)) } + fn create_multiple_items_nft(b: u32, ) -> Weight { + (336_830_000 as Weight) + // Standard Error: 42_000 + .saturating_add((11_627_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(RocksDbWeight::get().reads(11 as Weight)) + .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + } fn create_item_fungible() -> Weight { - (22_331_000 as Weight) + (24_123_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(9 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + } + fn create_multiple_items_fungible(b: u32, ) -> Weight { + (13_217_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_971_000 as Weight).saturating_mul(b as Weight)) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -289,6 +338,14 @@ .saturating_add(RocksDbWeight::get().reads(9 as Weight)) .saturating_add(RocksDbWeight::get().writes(7 as Weight)) } + fn create_multiple_items_refungible(b: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 16_000 + .saturating_add((8_374_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(RocksDbWeight::get().reads(9 as Weight)) + .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + } fn burn_item_nft() -> Weight { (32_237_000 as Weight) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) @@ -309,6 +366,11 @@ .saturating_add(RocksDbWeight::get().reads(10 as Weight)) .saturating_add(RocksDbWeight::get().writes(7 as Weight)) } + fn set_transfers_enabled_flag() -> Weight { + (6_376_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } fn approve_nft() -> Weight { (169_825_000 as Weight) .saturating_add(RocksDbWeight::get().reads(9 as Weight)) -- gitstuff