Skip to content

Commit

Permalink
Migrated Initializer benchmarking to V2
Browse files Browse the repository at this point in the history
  • Loading branch information
Krayt78 committed Nov 22, 2024
1 parent 8d4138f commit 166c5d7
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 166c5d7

Please sign in to comment.