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

Migrated benchmarking of flexible-fee from v1 to v2. #1523

Merged
merged 1 commit into from
Nov 28, 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
31 changes: 21 additions & 10 deletions pallets/flexible-fee/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#![cfg(feature = "runtime-benchmarks")]

use frame_benchmarking::v1::{benchmarks, whitelisted_caller};
use frame_benchmarking::v2::*;
use frame_support::BoundedVec;

use bifrost_primitives::{CurrencyId, TokenSymbol};
Expand All @@ -27,17 +27,28 @@ use sp_std::vec;

use crate::{Call, Config, Pallet};

benchmarks! {
set_user_default_fee_currency {
#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn set_user_default_fee_currency() -> Result<(), BenchmarkError> {
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller),Some(CurrencyId::Token(TokenSymbol::DOT)))

set_default_fee_currency_list {
#[extrinsic_call]
_(RawOrigin::Signed(caller), Some(CurrencyId::Token(TokenSymbol::DOT)));

Ok(())
}

#[benchmark]
fn set_default_fee_currency_list() -> Result<(), BenchmarkError> {
let default_list = BoundedVec::try_from(vec![CurrencyId::Token(TokenSymbol::DOT)]).unwrap();
}: _(RawOrigin::Root,default_list)

impl_benchmark_test_suite!(
Pallet,
crate::mock::new_test_ext(),
crate::mock::Test)
#[extrinsic_call]
_(RawOrigin::Root, default_list);

Ok(())
}
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext_benchmark(), crate::mock::Test);
}
13 changes: 13 additions & 0 deletions pallets/flexible-fee/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,16 @@ impl BalanceCmp<AccountId> for Test {
Pallet::<Test>::cmp_with_precision(account, currency, amount, amount_precision)
}
}

pub struct ExtBuilder;

impl ExtBuilder {
pub fn build(self) -> sp_io::TestExternalities {
new_test_ext()
}
}

#[cfg(feature = "runtime-benchmarks")]
pub fn new_test_ext_benchmark() -> sp_io::TestExternalities {
ExtBuilder.build()
}
24 changes: 12 additions & 12 deletions pallets/flexible-fee/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

//! Autogenerated weights for bifrost_flexible_fee
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-09-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-11-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `mjl-legion`, CPU: `12th Gen Intel(R) Core(TM) i9-12900H`
//! WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-kusama-local"), DB CACHE: 1024

// Executed Command:
Expand All @@ -36,7 +36,7 @@
// --chain=bifrost-kusama-local
// --steps=50
// --repeat=20
// --pallet=bifrost_flexible_fee
// --pallet=bifrost_flexible-fee
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
Expand All @@ -59,24 +59,24 @@ pub trait WeightInfo {

// For backwards compatibility and tests
impl WeightInfo for () {
/// Storage: FlexibleFee UserDefaultFeeCurrency (r:0 w:1)
/// Proof Skipped: FlexibleFee UserDefaultFeeCurrency (max_values: None, max_size: None, mode: Measured)
/// Storage: `FlexibleFee::UserDefaultFeeCurrency` (r:0 w:1)
/// Proof: `FlexibleFee::UserDefaultFeeCurrency` (`max_values`: None, `max_size`: Some(54), added: 2529, mode: `MaxEncodedLen`)
fn set_user_default_fee_currency() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 11_322_000 picoseconds.
Weight::from_parts(11_925_000, 0)
// Minimum execution time: 3_734_000 picoseconds.
Weight::from_parts(3_996_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: FlexibleFee UniversalFeeCurrencyOrderList (r:0 w:1)
/// Proof Skipped: FlexibleFee UniversalFeeCurrencyOrderList (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: `FlexibleFee::UniversalFeeCurrencyOrderList` (r:0 w:1)
/// Proof: `FlexibleFee::UniversalFeeCurrencyOrderList` (`max_values`: Some(1), `max_size`: Some(701), added: 1196, mode: `MaxEncodedLen`)
fn set_default_fee_currency_list() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 10_424_000 picoseconds.
Weight::from_parts(10_846_000, 0)
// Minimum execution time: 3_257_000 picoseconds.
Weight::from_parts(3_404_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}