-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ismp-grandpa): add benchmarking support
- Add WeightInfo trait and default implementation - Integrate benchmarking feature flag and dependencies - Configure benchmarking in Gargantua and Nexus runtimes - Add placeholder weight values for pallet extrinsics This implements benchmarking support for ismp-grandpa, addressing #350.
- Loading branch information
1 parent
46da0fb
commit 8507b80
Showing
9 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![cfg(feature = "runtime-benchmarks")] | ||
|
||
use super::*; | ||
use frame_benchmarking::v2::*; | ||
use frame_system::RawOrigin; | ||
use ismp::host::StateMachine; | ||
|
||
#[benchmarks(where T: Config)] | ||
mod benchmarks { | ||
use super::*; | ||
|
||
#[benchmark] | ||
fn add_state_machines() -> Result<(), BenchmarkError> { | ||
let state_machines: Vec<AddStateMachine> = (0..10) | ||
.map(|i| AddStateMachine { | ||
state_machine: StateMachine::Polkadot(i as u32), | ||
slot_duration: 6000, | ||
}) | ||
.collect(); | ||
|
||
#[block] | ||
{ | ||
Pallet::<T>::add_state_machines(RawOrigin::Root.into(), state_machines)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[benchmark] | ||
fn remove_state_machines() -> Result<(), BenchmarkError> { | ||
let state_machines: Vec<StateMachine> = (0..10) | ||
.map(|i| StateMachine::Polkadot(i as u32)) | ||
.collect(); | ||
|
||
for i in 0..10 { | ||
SupportedStateMachines::<T>::insert( | ||
StateMachine::Polkadot(i as u32), | ||
6000 | ||
); | ||
} | ||
|
||
#[block] | ||
{ | ||
Pallet::<T>::remove_state_machines(RawOrigin::Root.into(), state_machines)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// This file is part of Hyperbridge. | ||
|
||
// Copyright (C) Polytope Labs Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
#![cfg_attr(rustfmt, rustfmt_skip)] | ||
#![allow(unused_parens)] | ||
#![allow(unused_imports)] | ||
|
||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; | ||
use sp_std::marker::PhantomData; | ||
|
||
/// Weights for ismp_grandpa | ||
pub struct WeightInfo<T>(PhantomData<T>); | ||
|
||
impl<T: frame_system::Config> crate::WeightInfo for WeightInfo<T> { | ||
fn add_state_machines() -> Weight { | ||
Weight::from_parts(20_000, 0) | ||
.saturating_add(T::DbWeight::get().writes(10)) | ||
} | ||
|
||
fn remove_state_machines() -> Weight { | ||
Weight::from_parts(20_000, 0) | ||
.saturating_add(T::DbWeight::get().writes(10)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters