Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify foreign asset creator benches to make them non-parametric #36

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions pallets/foreign-asset-creator/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,45 +37,38 @@ benchmarks! {
}

change_existing_asset_type {
// We make it dependent on the number of existing assets already
let x in 5..100;
const USER_SEED: u32 = 1;
let manager: T::AccountId = account("manager", 0, USER_SEED);

for i in 0..x {
let foreign_asset: T::ForeignAsset = Location::new(0, [GeneralIndex(i as u128)]).into();
let asset_id: AssetId<T> = (i as u16).into();
let amount = 1u32.into();
Pallet::<T>::create_foreign_asset(
RawOrigin::Root.into(),
foreign_asset.clone(),
asset_id.clone(),
manager.clone(),
true,
amount,
)?;
}
let foreign_asset: T::ForeignAsset = Location::new(0, [GeneralIndex(0u128)]).into();
let asset_id: AssetId<T> = (0u16).into();
let amount = 1u32.into();
Pallet::<T>::create_foreign_asset(
RawOrigin::Root.into(),
foreign_asset.clone(),
asset_id.clone(),
manager.clone(),
true,
amount,
)?;

let new_foreign_asset = T::ForeignAsset::default();
let asset_type_to_be_changed: T::ForeignAsset = Location::new(
0,
[GeneralIndex((x-1) as u128)]
[GeneralIndex((0) as u128)]
).into();
let asset_id_to_be_changed: AssetId<T> = ((x-1) as u16).into();
let asset_id_to_be_changed: AssetId<T> = (0u16).into();
}: _(RawOrigin::Root, asset_id_to_be_changed.clone(), new_foreign_asset.clone())
verify {
assert_eq!(Pallet::<T>::foreign_asset_for_id(asset_id_to_be_changed), Some(new_foreign_asset.clone()));
}

remove_existing_asset_type {
// We make it dependent on the number of existing assets already
let x in 5..100;
const USER_SEED: u32 = 1;
let manager: T::AccountId = account("manager", 0, USER_SEED);

for i in 0..x {
let foreign_asset: T::ForeignAsset = Location::new(0, [GeneralIndex(i as u128)]).into();
let asset_id: AssetId<T> = (i as u16).into();
let foreign_asset: T::ForeignAsset = Location::new(0, [GeneralIndex(0u128)]).into();
let asset_id: AssetId<T> = 0u16.into();
let amount = 1u32.into();
Pallet::<T>::create_foreign_asset(
RawOrigin::Root.into(),
Expand All @@ -85,23 +78,19 @@ benchmarks! {
true,
amount,
)?;
}

let asset_id_to_be_removed: AssetId<T> = ((x-1) as u16).into();
let asset_id_to_be_removed: AssetId<T> = 0u16.into();
}: _(RawOrigin::Root, asset_id_to_be_removed.clone())
verify {
assert!(Pallet::<T>::foreign_asset_for_id(asset_id_to_be_removed).is_none());
}

destroy_foreign_asset {
// We make it dependent on the number of existing assets already
let x in 5..100;
const USER_SEED: u32 = 1;
let manager: T::AccountId = account("manager", 0, USER_SEED);

for i in 0..x {
let foreign_asset: T::ForeignAsset = Location::new(0, [GeneralIndex(i as u128)]).into();
let asset_id: AssetId<T> = (i as u16).into();
let foreign_asset: T::ForeignAsset = Location::new(0, [GeneralIndex(0u128)]).into();
let asset_id: AssetId<T> = 0u16.into();
let amount = 1u32.into();
Pallet::<T>::create_foreign_asset(
RawOrigin::Root.into(),
Expand All @@ -111,9 +100,8 @@ benchmarks! {
true,
amount,
)?;
}

let asset_id_to_be_destroyed: AssetId<T> = ((x-1) as u16).into();
let asset_id_to_be_destroyed: AssetId<T> = 0u16.into();
}: _(RawOrigin::Root, asset_id_to_be_destroyed.clone())
verify {
assert!(Pallet::<T>::foreign_asset_for_id(asset_id_to_be_destroyed).is_none());
Expand Down
75 changes: 35 additions & 40 deletions pallets/foreign-asset-creator/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
//! Autogenerated weights for pallet_foreign_asset_creator
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-01-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-04-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `girazoki-XPS-15-9530`, CPU: `13th Gen Intel(R) Core(TM) i9-13900H`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
// ./target/release/tanssi-node
Expand All @@ -33,6 +33,7 @@
// pallet_foreign_asset_creator
// --extrinsic
// *
// --chain=dev
// --steps
// 50
// --repeat
Expand All @@ -41,7 +42,7 @@
// --json-file
// raw.json
// --output
// weights.rs
// tmp/pallet_foreign_asset_creator.rs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand Down Expand Up @@ -69,10 +70,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn create_foreign_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `80`
// Measured: `113`
// Estimated: `3673`
// Minimum execution time: 17_654_000 picoseconds.
Weight::from_parts(18_621_000, 3673)
// Minimum execution time: 16_738_000 picoseconds.
Weight::from_parts(17_366_000, 3673)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -82,11 +83,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn change_existing_asset_type() -> Weight {
// Proof Size summary in bytes:
// Measured: `427`
// Estimated: `3880`
// Minimum execution time: 17_469_000 picoseconds.
Weight::from_parts(20_276_697, 3880)
// Standard Error: 1_876
// Measured: `189`
// Estimated: `3654`
// Minimum execution time: 13_861_000 picoseconds.
Weight::from_parts(14_153_000, 3654)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -96,11 +96,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn remove_existing_asset_type() -> Weight {
// Proof Size summary in bytes:
// Measured: `427`
// Estimated: `3880`
// Minimum execution time: 15_165_000 picoseconds.
Weight::from_parts(18_041_533, 3880)
// Standard Error: 1_836
// Measured: `189`
// Estimated: `3654`
// Minimum execution time: 11_698_000 picoseconds.
Weight::from_parts(12_184_000, 3654)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -112,14 +111,13 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn destroy_foreign_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `981`
// Estimated: `4441`
// Minimum execution time: 22_589_000 picoseconds.
Weight::from_parts(26_897_574, 4441)
// Standard Error: 3_872
// Measured: `429`
// Estimated: `3894`
// Minimum execution time: 17_797_000 picoseconds.
Weight::from_parts(18_635_000, 3894)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
}
}

// For backwards compatibility and tests
Expand All @@ -132,10 +130,10 @@ impl WeightInfo for () {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn create_foreign_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `80`
// Measured: `113`
// Estimated: `3673`
// Minimum execution time: 17_654_000 picoseconds.
Weight::from_parts(18_621_000, 3673)
// Minimum execution time: 16_738_000 picoseconds.
Weight::from_parts(17_366_000, 3673)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand All @@ -145,11 +143,10 @@ impl WeightInfo for () {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn change_existing_asset_type() -> Weight {
// Proof Size summary in bytes:
// Measured: `427`
// Estimated: `3880`
// Minimum execution time: 17_469_000 picoseconds.
Weight::from_parts(20_276_697, 3880)
// Standard Error: 1_876
// Measured: `189`
// Estimated: `3654`
// Minimum execution time: 13_861_000 picoseconds.
Weight::from_parts(14_153_000, 3654)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand All @@ -159,11 +156,10 @@ impl WeightInfo for () {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn remove_existing_asset_type() -> Weight {
// Proof Size summary in bytes:
// Measured: `427`
// Estimated: `3880`
// Minimum execution time: 15_165_000 picoseconds.
Weight::from_parts(18_041_533, 3880)
// Standard Error: 1_836
// Measured: `189`
// Estimated: `3654`
// Minimum execution time: 11_698_000 picoseconds.
Weight::from_parts(12_184_000, 3654)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -175,11 +171,10 @@ impl WeightInfo for () {
/// Proof: `ForeignAssetsCreator::ForeignAssetToAssetId` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn destroy_foreign_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `981`
// Estimated: `4441`
// Minimum execution time: 22_589_000 picoseconds.
Weight::from_parts(26_897_574, 4441)
// Standard Error: 3_872
// Measured: `429`
// Estimated: `3894`
// Minimum execution time: 17_797_000 picoseconds.
Weight::from_parts(18_635_000, 3894)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand Down
Loading