mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
Use define_benchmarks! (#4760)
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
committed by
GitHub
parent
8756678a83
commit
cc1201ef27
@@ -2947,6 +2947,57 @@ impl OnRuntimeUpgrade for SessionHistoricalPalletPrefixMigration {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
#[macro_use]
|
||||
extern crate frame_benchmarking;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benches {
|
||||
define_benchmarks!(
|
||||
// Polkadot
|
||||
// NOTE: Make sure to prefix these with `runtime_common::` so
|
||||
// the that path resolves correctly in the generated file.
|
||||
[runtime_common::auctions, Auctions]
|
||||
[runtime_common::crowdloan, Crowdloan]
|
||||
[runtime_common::claims, Claims]
|
||||
[runtime_common::slots, Slots]
|
||||
[runtime_common::paras_registrar, Registrar]
|
||||
[runtime_parachains::configuration, Configuration]
|
||||
[runtime_parachains::hrmp, Hrmp]
|
||||
[runtime_parachains::disputes, ParasDisputes]
|
||||
[runtime_parachains::initializer, Initializer]
|
||||
[runtime_parachains::paras_inherent, ParaInherent]
|
||||
[runtime_parachains::paras, Paras]
|
||||
// Substrate
|
||||
[pallet_balances, Balances]
|
||||
[pallet_bags_list, BagsList]
|
||||
[pallet_bounties, Bounties]
|
||||
[pallet_collective, Council]
|
||||
[pallet_collective, TechnicalCommittee]
|
||||
[pallet_democracy, Democracy]
|
||||
[pallet_elections_phragmen, PhragmenElection]
|
||||
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
|
||||
[pallet_gilt, Gilt]
|
||||
[pallet_identity, Identity]
|
||||
[pallet_im_online, ImOnline]
|
||||
[pallet_indices, Indices]
|
||||
[pallet_membership, TechnicalMembership]
|
||||
[pallet_multisig, Multisig]
|
||||
[pallet_offences, OffencesBench::<Runtime>]
|
||||
[pallet_preimage, Preimage]
|
||||
[pallet_proxy, Proxy]
|
||||
[pallet_scheduler, Scheduler]
|
||||
[pallet_session, SessionBench::<Runtime>]
|
||||
[pallet_staking, Staking]
|
||||
[frame_system, SystemBench::<Runtime>]
|
||||
[pallet_timestamp, Timestamp]
|
||||
[pallet_tips, Tips]
|
||||
[pallet_treasury, Treasury]
|
||||
[pallet_utility, Utility]
|
||||
[pallet_vesting, Vesting]
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
sp_api::impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
@@ -3280,7 +3331,7 @@ sp_api::impl_runtime_apis! {
|
||||
Vec<frame_benchmarking::BenchmarkList>,
|
||||
Vec<frame_support::traits::StorageInfo>,
|
||||
) {
|
||||
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkList};
|
||||
use frame_support::traits::StorageInfoTrait;
|
||||
|
||||
use pallet_session_benchmarking::Pallet as SessionBench;
|
||||
@@ -3288,51 +3339,9 @@ sp_api::impl_runtime_apis! {
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
|
||||
let mut list = Vec::<BenchmarkList>::new();
|
||||
|
||||
// Polkadot
|
||||
// NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly
|
||||
// in the generated file.
|
||||
list_benchmark!(list, extra, runtime_common::auctions, Auctions);
|
||||
list_benchmark!(list, extra, runtime_common::crowdloan, Crowdloan);
|
||||
list_benchmark!(list, extra, runtime_common::claims, Claims);
|
||||
list_benchmark!(list, extra, runtime_common::slots, Slots);
|
||||
list_benchmark!(list, extra, runtime_common::paras_registrar, Registrar);
|
||||
list_benchmark!(list, extra, runtime_parachains::configuration, Configuration);
|
||||
list_benchmark!(list, extra, runtime_parachains::hrmp, Hrmp);
|
||||
list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes);
|
||||
list_benchmark!(list, extra, runtime_parachains::initializer, Initializer);
|
||||
list_benchmark!(list, extra, runtime_parachains::paras_inherent, ParaInherent);
|
||||
list_benchmark!(list, extra, runtime_parachains::paras, Paras);
|
||||
// Substrate
|
||||
list_benchmark!(list, extra, pallet_bags_list, BagsList);
|
||||
list_benchmark!(list, extra, pallet_balances, Balances);
|
||||
list_benchmark!(list, extra, pallet_bounties, Bounties);
|
||||
list_benchmark!(list, extra, pallet_collective, Council);
|
||||
list_benchmark!(list, extra, pallet_collective, TechnicalCommittee);
|
||||
list_benchmark!(list, extra, pallet_democracy, Democracy);
|
||||
list_benchmark!(list, extra, pallet_elections_phragmen, PhragmenElection);
|
||||
list_benchmark!(list, extra, pallet_election_provider_multi_phase, ElectionProviderMultiPhase);
|
||||
list_benchmark!(list, extra, pallet_gilt, Gilt);
|
||||
list_benchmark!(list, extra, pallet_identity, Identity);
|
||||
list_benchmark!(list, extra, pallet_im_online, ImOnline);
|
||||
list_benchmark!(list, extra, pallet_indices, Indices);
|
||||
list_benchmark!(list, extra, pallet_membership, TechnicalMembership);
|
||||
list_benchmark!(list, extra, pallet_multisig, Multisig);
|
||||
list_benchmark!(list, extra, pallet_offences, OffencesBench::<Runtime>);
|
||||
list_benchmark!(list, extra, pallet_preimage, Preimage);
|
||||
list_benchmark!(list, extra, pallet_proxy, Proxy);
|
||||
list_benchmark!(list, extra, pallet_scheduler, Scheduler);
|
||||
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
|
||||
list_benchmark!(list, extra, pallet_staking, Staking);
|
||||
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
|
||||
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
|
||||
list_benchmark!(list, extra, pallet_tips, Tips);
|
||||
list_benchmark!(list, extra, pallet_treasury, Treasury);
|
||||
list_benchmark!(list, extra, pallet_utility, Utility);
|
||||
list_benchmark!(list, extra, pallet_vesting, Vesting);
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
|
||||
return (list, storage_info)
|
||||
}
|
||||
|
||||
@@ -3342,7 +3351,7 @@ sp_api::impl_runtime_apis! {
|
||||
Vec<frame_benchmarking::BenchmarkBatch>,
|
||||
sp_runtime::RuntimeString,
|
||||
> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
// Trying to add benchmarks directly to some pallets caused cyclic dependency issues.
|
||||
// To get around that, we separated the benchmarks into its own crate.
|
||||
use pallet_session_benchmarking::Pallet as SessionBench;
|
||||
@@ -3370,47 +3379,8 @@ sp_api::impl_runtime_apis! {
|
||||
|
||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||
let params = (&config, &whitelist);
|
||||
// Polkadot
|
||||
// NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly
|
||||
// in the generated file.
|
||||
add_benchmark!(params, batches, runtime_common::auctions, Auctions);
|
||||
add_benchmark!(params, batches, runtime_common::crowdloan, Crowdloan);
|
||||
add_benchmark!(params, batches, runtime_common::claims, Claims);
|
||||
add_benchmark!(params, batches, runtime_common::slots, Slots);
|
||||
add_benchmark!(params, batches, runtime_common::paras_registrar, Registrar);
|
||||
add_benchmark!(params, batches, runtime_parachains::configuration, Configuration);
|
||||
add_benchmark!(params, batches, runtime_parachains::hrmp, Hrmp);
|
||||
add_benchmark!(params, batches, runtime_parachains::disputes, ParasDisputes);
|
||||
add_benchmark!(params, batches, runtime_parachains::initializer, Initializer);
|
||||
add_benchmark!(params, batches, runtime_parachains::paras_inherent, ParaInherent);
|
||||
add_benchmark!(params, batches, runtime_parachains::paras, Paras);
|
||||
// Substrate
|
||||
add_benchmark!(params, batches, pallet_balances, Balances);
|
||||
add_benchmark!(params, batches, pallet_bags_list, BagsList);
|
||||
add_benchmark!(params, batches, pallet_bounties, Bounties);
|
||||
add_benchmark!(params, batches, pallet_collective, Council);
|
||||
add_benchmark!(params, batches, pallet_collective, TechnicalCommittee);
|
||||
add_benchmark!(params, batches, pallet_democracy, Democracy);
|
||||
add_benchmark!(params, batches, pallet_elections_phragmen, PhragmenElection);
|
||||
add_benchmark!(params, batches, pallet_election_provider_multi_phase, ElectionProviderMultiPhase);
|
||||
add_benchmark!(params, batches, pallet_gilt, Gilt);
|
||||
add_benchmark!(params, batches, pallet_identity, Identity);
|
||||
add_benchmark!(params, batches, pallet_im_online, ImOnline);
|
||||
add_benchmark!(params, batches, pallet_indices, Indices);
|
||||
add_benchmark!(params, batches, pallet_membership, TechnicalMembership);
|
||||
add_benchmark!(params, batches, pallet_multisig, Multisig);
|
||||
add_benchmark!(params, batches, pallet_offences, OffencesBench::<Runtime>);
|
||||
add_benchmark!(params, batches, pallet_preimage, Preimage);
|
||||
add_benchmark!(params, batches, pallet_proxy, Proxy);
|
||||
add_benchmark!(params, batches, pallet_scheduler, Scheduler);
|
||||
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
|
||||
add_benchmark!(params, batches, pallet_staking, Staking);
|
||||
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
|
||||
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
|
||||
add_benchmark!(params, batches, pallet_tips, Tips);
|
||||
add_benchmark!(params, batches, pallet_treasury, Treasury);
|
||||
add_benchmark!(params, batches, pallet_utility, Utility);
|
||||
add_benchmark!(params, batches, pallet_vesting, Vesting);
|
||||
|
||||
add_benchmarks!(params, batches);
|
||||
|
||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
||||
Ok(batches)
|
||||
|
||||
Reference in New Issue
Block a user