Skip to content

Commit

Permalink
apply staking period benchmarking department-funding
Browse files Browse the repository at this point in the history
  • Loading branch information
amiyatulu committed Oct 10, 2024
1 parent db96b68 commit 3eb9c45
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 6 deletions.
48 changes: 47 additions & 1 deletion custom-pallets/department-funding/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod benchmarks {

#[benchmark]
fn create_department_required_fund() {
let account_id = 1;
let department_id = 1;
let tipping_name = TippingName::SmallTipper;

Expand Down Expand Up @@ -59,5 +58,52 @@ mod benchmarks {
);
}

#[benchmark]
fn apply_staking_period() {
let department_id = 1;
let tipping_name = TippingName::SmallTipper;

let account1 = account::<T::AccountId>("account1", 1, SEED);

let balance = DepartmentFunding::<T>::u64_to_balance_saturated(100000000000000);

let _ = <T as pallet::Config>::Currency::deposit_creating(&account1, balance);

let funding_needed = DepartmentFunding::<T>::u64_to_balance_saturated(10_000u64);
// Dispatch a signed extrinsic.
let department_account_id = 5;
let content_department: Content = Content::IPFS(
"bafkreiaiq24be2iioasr6ftyaum3icmj7amtjkom2jeokov5k5ojwzhvqy"
.as_bytes()
.to_vec(),
);

assert_ok!(<pallet_departments::Pallet<T>>::create_department(
RawOrigin::Signed(account1.clone()).into(),
content_department
));

let content: Content = Content::IPFS(
"bafkreiaiq24be2iioasr6ftyaum3icmj7amtjkom2jeokov5k5ojwzhvqy"
.as_bytes()
.to_vec(),
);

assert_ok!(DepartmentFunding::<T>::create_department_required_fund(
RawOrigin::Signed(account1.clone()).into(),
department_id,
content.clone(),
tipping_name,
funding_needed,
));

let start_block_number = DepartmentFunding::<T>::u64_to_block_saturated(50);

<frame_system::Pallet<T>>::set_block_number(start_block_number);

#[extrinsic_call]
apply_staking_period(RawOrigin::Signed(account1), department_id)
}

impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test);
}
53 changes: 48 additions & 5 deletions custom-pallets/department-funding/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Autogenerated weights for `pallet_department_funding`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-10-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-10-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `amiya`, CPU: `12th Gen Intel(R) Core(TM) i7-12650H`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
Expand Down Expand Up @@ -38,6 +38,7 @@ use core::marker::PhantomData;
/// Weight functions needed for `pallet_department_funding`.
pub trait WeightInfo {
fn create_department_required_fund() -> Weight;
fn apply_staking_period() -> Weight;
}

/// Weights for `pallet_department_funding` using the Substrate node and recommended hardware.
Expand All @@ -57,11 +58,32 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `345`
// Estimated: `3810`
// Minimum execution time: 26_415_000 picoseconds.
Weight::from_parts(27_367_000, 3810)
// Minimum execution time: 28_476_000 picoseconds.
Weight::from_parts(29_780_000, 3810)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `DepartmentFunding::DepartmentRequiredFunds` (r:1 w:0)
/// Proof: `DepartmentFunding::DepartmentRequiredFunds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `DepartmentFunding::DepartmentFundingStatusForDepartmentId` (r:1 w:1)
/// Proof: `DepartmentFunding::DepartmentFundingStatusForDepartmentId` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `SchellingGameShared::PeriodName` (r:1 w:1)
/// Proof: `SchellingGameShared::PeriodName` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `SortitionSumGame::SortitionSumTrees` (r:1 w:1)
/// Proof: `SortitionSumGame::SortitionSumTrees` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `SchellingGameShared::StakingStartTime` (r:0 w:1)
/// Proof: `SchellingGameShared::StakingStartTime` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `DepartmentFunding::ValidationBlock` (r:0 w:1)
/// Proof: `DepartmentFunding::ValidationBlock` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn apply_staking_period() -> Weight {
// Proof Size summary in bytes:
// Measured: `306`
// Estimated: `3771`
// Minimum execution time: 26_841_000 picoseconds.
Weight::from_parts(28_235_000, 3771)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
}

// For backwards compatibility and tests.
Expand All @@ -80,9 +102,30 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `345`
// Estimated: `3810`
// Minimum execution time: 26_415_000 picoseconds.
Weight::from_parts(27_367_000, 3810)
// Minimum execution time: 28_476_000 picoseconds.
Weight::from_parts(29_780_000, 3810)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
/// Storage: `DepartmentFunding::DepartmentRequiredFunds` (r:1 w:0)
/// Proof: `DepartmentFunding::DepartmentRequiredFunds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `DepartmentFunding::DepartmentFundingStatusForDepartmentId` (r:1 w:1)
/// Proof: `DepartmentFunding::DepartmentFundingStatusForDepartmentId` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `SchellingGameShared::PeriodName` (r:1 w:1)
/// Proof: `SchellingGameShared::PeriodName` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `SortitionSumGame::SortitionSumTrees` (r:1 w:1)
/// Proof: `SortitionSumGame::SortitionSumTrees` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `SchellingGameShared::StakingStartTime` (r:0 w:1)
/// Proof: `SchellingGameShared::StakingStartTime` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `DepartmentFunding::ValidationBlock` (r:0 w:1)
/// Proof: `DepartmentFunding::ValidationBlock` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn apply_staking_period() -> Weight {
// Proof Size summary in bytes:
// Measured: `306`
// Estimated: `3771`
// Minimum execution time: 26_841_000 picoseconds.
Weight::from_parts(28_235_000, 3771)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
}

0 comments on commit 3eb9c45

Please sign in to comment.