Skip to content

Commit

Permalink
Migrating polkadot-runtime-parachains initializer benchmarking to v2 (#…
Browse files Browse the repository at this point in the history
…6612)

# Description
Migrated polkadot-runtime-parachains initializer benchmarking to the new
benchmarking syntax v2.
This is part of #6202

Co-authored-by: Giuseppe Re <giuseppe.re@parity.io>
  • Loading branch information
Krayt78 and re-gius authored Feb 26, 2025
1 parent 7211692 commit 959f104
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions polkadot/runtime/parachains/src/initializer/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,33 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use super::*;
use frame_benchmarking::benchmarks;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use polkadot_primitives::ConsensusLog;
use sp_runtime::DigestItem;

// Random large number for the digest
const DIGEST_MAX_LEN: u32 = 65536;

benchmarks! {
force_approve {
let d in 0 .. DIGEST_MAX_LEN;
for _ in 0 .. d {
#[benchmarks]
mod benchmarks {
use super::*;

#[benchmark]
fn force_approve(d: Linear<0, DIGEST_MAX_LEN>) -> Result<(), BenchmarkError> {
for _ in 0..d {
frame_system::Pallet::<T>::deposit_log(ConsensusLog::ForceApprove(d).into());
}
}: _(RawOrigin::Root, d + 1)
verify {

#[extrinsic_call]
_(RawOrigin::Root, d + 1);

assert_eq!(
frame_system::Pallet::<T>::digest().logs.last().unwrap(),
&DigestItem::from(ConsensusLog::ForceApprove(d + 1)),
);

Ok(())
}

impl_benchmark_test_suite!(
Expand Down

0 comments on commit 959f104

Please sign in to comment.