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.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_structure4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-03-24, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-structure14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/structure/src/weights.rs2425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_structure.34pub trait WeightInfo {35 fn find_parent() -> Weight;36}3738/// Weights for pallet_structure using the Substrate node and recommended hardware.39pub struct SubstrateWeight<T>(PhantomData<T>);40impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {41 // Storage: Common CollectionById (r:1 w:0)42 // Storage: Nonfungible TokenData (r:1 w:0)43 fn find_parent() -> Weight {44 (6_302_000 as Weight)45 .saturating_add(T::DbWeight::get().reads(2 as Weight))46 }47}4849// For backwards compatibility and tests50impl WeightInfo for () {51 // Storage: Common CollectionById (r:1 w:0)52 // Storage: Nonfungible TokenData (r:1 w:0)53 fn find_parent() -> Weight {54 (6_302_000 as Weight)55 .saturating_add(RocksDbWeight::get().reads(2 as Weight))56 }57}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',