referrerpolicy=no-referrer-when-downgrade

polkadot_runtime_parachains/configuration/
benchmarking.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16#![cfg(feature = "runtime-benchmarks")]
17
18use crate::configuration::*;
19use frame_benchmarking::v2::*;
20use frame_system::RawOrigin;
21use polkadot_primitives::{ExecutorParam, ExecutorParams, PvfExecKind, PvfPrepKind};
22use sp_runtime::traits::One;
23
24#[benchmarks]
25mod benchmarks {
26	use super::*;
27
28	#[benchmark]
29	fn set_config_with_block_number() {
30		#[extrinsic_call]
31		set_code_retention_period(RawOrigin::Root, One::one());
32	}
33
34	#[benchmark]
35	fn set_config_with_u32() {
36		#[extrinsic_call]
37		set_max_code_size(RawOrigin::Root, 100);
38	}
39
40	#[benchmark]
41	fn set_config_with_option_u32() {
42		#[extrinsic_call]
43		set_max_validators(RawOrigin::Root, Some(10));
44	}
45
46	#[benchmark]
47	fn set_hrmp_open_request_ttl() -> Result<(), BenchmarkError> {
48		#[block]
49		{
50			Err(BenchmarkError::Override(BenchmarkResult::from_weight(
51				T::BlockWeights::get().max_block,
52			)))?;
53		}
54		Ok(())
55	}
56
57	#[benchmark]
58	fn set_config_with_balance() {
59		#[extrinsic_call]
60		set_hrmp_sender_deposit(RawOrigin::Root, 100_000_000_000);
61	}
62
63	#[benchmark]
64	fn set_config_with_executor_params() {
65		#[extrinsic_call]
66		set_executor_params(
67			RawOrigin::Root,
68			ExecutorParams::from(
69				&[
70					ExecutorParam::MaxMemoryPages(2080),
71					ExecutorParam::StackLogicalMax(65536),
72					ExecutorParam::StackNativeMax(256 * 1024 * 1024),
73					ExecutorParam::WasmExtBulkMemory,
74					ExecutorParam::PrecheckingMaxMemory(2 * 1024 * 1024 * 1024),
75					ExecutorParam::PvfPrepTimeout(PvfPrepKind::Precheck, 60_000),
76					ExecutorParam::PvfPrepTimeout(PvfPrepKind::Prepare, 360_000),
77					ExecutorParam::PvfExecTimeout(PvfExecKind::Backing, 2_000),
78					ExecutorParam::PvfExecTimeout(PvfExecKind::Approval, 12_000),
79				][..],
80			),
81		);
82	}
83
84	#[benchmark]
85	fn set_config_with_perbill() {
86		#[extrinsic_call]
87		set_on_demand_fee_variability(RawOrigin::Root, Perbill::from_percent(100));
88	}
89
90	#[benchmark]
91	fn set_node_feature() {
92		#[extrinsic_call]
93		set_node_feature(RawOrigin::Root, 255, true);
94	}
95
96	#[benchmark]
97	fn set_config_with_scheduler_params() {
98		#[extrinsic_call]
99		set_scheduler_params(RawOrigin::Root, SchedulerParams::default());
100	}
101
102	impl_benchmark_test_suite!(
103		Pallet,
104		crate::mock::new_test_ext(Default::default()),
105		crate::mock::Test
106	);
107}