difftreelog
feat benchmark structure
in: master
9 files changed
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -57,5 +57,9 @@
bench-nonfungible:
make _bench PALLET=nonfungible
+.PHONY: bench-structure
+bench-structure:
+ make _bench PALLET=structure
+
.PHONY: bench
-bench: bench-evm-migration bench-unique bench-fungible bench-refungible bench-nonfungible
+bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible
pallets/structure/Cargo.tomldiffbeforeafterboth--- a/pallets/structure/Cargo.toml
+++ b/pallets/structure/Cargo.toml
@@ -6,6 +6,7 @@
[dependencies]
frame-support = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.17' }
frame-system = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.17' }
+frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.17' }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.17' }
pallet-common = { path = "../common", default-features = false }
parity-scale-codec = { version = "2.0.0", default-features = false, features = [
@@ -21,9 +22,11 @@
std = [
"frame-support/std",
"frame-system/std",
+ "frame-benchmarking/std",
"sp-std/std",
"pallet-common/std",
"scale-info/std",
"parity-scale-codec/std",
"up-data-structs/std",
]
+runtime-benchmarks = ['frame-benchmarking', 'pallet-common/runtime-benchmarks']
pallets/structure/src/benchmarking.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/structure/src/benchmarking.rs
@@ -0,0 +1,28 @@
+use super::*;
+
+use frame_benchmarking::{benchmarks, account};
+use frame_support::traits::{Currency, Get};
+use up_data_structs::{CreateCollectionData, CollectionMode, CreateItemData, CreateNftData};
+use pallet_common::CrossAccountId;
+
+const SEED: u32 = 1;
+
+benchmarks! {
+ find_parent {
+ let caller: T::AccountId = account("caller", 0, SEED);
+ let caller_cross = T::CrossAccountId::from_sub(caller.clone());
+
+ T::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
+ T::CollectionDispatch::create(caller, CreateCollectionData {
+ mode: CollectionMode::NFT,
+ ..Default::default()
+ })?;
+ let dispatch = T::CollectionDispatch::dispatch(CollectionHandle::try_get(CollectionId(1))?);
+ let dispatch = dispatch.as_dyn();
+
+ dispatch.create_item(caller_cross.clone(), caller_cross.clone(), CreateItemData::NFT(CreateNftData::default()))?;
+ }: {
+ let parent = <Pallet<T>>::find_parent(CollectionId(1), TokenId(1))?;
+ assert!(matches!(parent, Parent::Normal(_)))
+ }
+}
pallets/structure/src/weights.rsdiffbeforeafterbothno changes
runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -378,6 +378,7 @@
list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
list_benchmark!(list, extra, pallet_unique, Unique);
+ list_benchmark!(list, extra, pallet_structure, Structure);
list_benchmark!(list, extra, pallet_inflation, Inflation);
list_benchmark!(list, extra, pallet_fungible, Fungible);
list_benchmark!(list, extra, pallet_refungible, Refungible);
@@ -415,6 +416,7 @@
add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
add_benchmark!(params, batches, pallet_unique, Unique);
+ add_benchmark!(params, batches, pallet_structure, Structure);
add_benchmark!(params, batches, pallet_inflation, Inflation);
add_benchmark!(params, batches, pallet_fungible, Fungible);
add_benchmark!(params, batches, pallet_refungible, Refungible);
runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -29,6 +29,7 @@
'pallet-balances/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'pallet-common/runtime-benchmarks',
+ 'pallet-structure/runtime-benchmarks',
'pallet-fungible/runtime-benchmarks',
'pallet-refungible/runtime-benchmarks',
'pallet-nonfungible/runtime-benchmarks',
@@ -84,6 +85,7 @@
'serde',
'pallet-inflation/std',
'pallet-common/std',
+ 'pallet-structure/std',
'pallet-fungible/std',
'pallet-refungible/std',
'pallet-nonfungible/std',
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -886,6 +886,7 @@
impl pallet_structure::Config for Runtime {
type Event = Event;
type Call = Call;
+ type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
}
impl pallet_fungible::Config for Runtime {
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -29,6 +29,7 @@
'pallet-balances/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'pallet-common/runtime-benchmarks',
+ 'pallet-structure/runtime-benchmarks',
'pallet-fungible/runtime-benchmarks',
'pallet-refungible/runtime-benchmarks',
'pallet-nonfungible/runtime-benchmarks',
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -29,6 +29,7 @@
'pallet-balances/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'pallet-common/runtime-benchmarks',
+ 'pallet-structure/runtime-benchmarks',
'pallet-fungible/runtime-benchmarks',
'pallet-refungible/runtime-benchmarks',
'pallet-nonfungible/runtime-benchmarks',