Skip to content
Snippets Groups Projects
Commit ab76ff53 authored by Oliver Tale-Yazdi's avatar Oliver Tale-Yazdi Committed by GitHub
Browse files

Use `define_benchmarks!` (#926)


Signed-off-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
parent 6ff23e90
Branches
No related merge requests found
...@@ -629,6 +629,21 @@ construct_runtime!( ...@@ -629,6 +629,21 @@ construct_runtime!(
} }
); );
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_collator_selection, CollatorSelection]
);
}
impl_runtime_apis! { impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration { fn slot_duration() -> sp_consensus_aura::SlotDuration {
...@@ -755,28 +770,22 @@ impl_runtime_apis! { ...@@ -755,28 +770,22 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>, Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>, Vec<frame_support::traits::StorageInfo>,
) { ) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait; use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
let mut list = Vec::<BenchmarkList>::new(); let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);
let storage_info = AllPalletsWithSystem::storage_info(); let storage_info = AllPalletsWithSystem::storage_info();
return (list, storage_info) return (list, storage_info)
} }
fn dispatch_benchmark( fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> { ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {}
...@@ -799,12 +808,7 @@ impl_runtime_apis! { ...@@ -799,12 +808,7 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new(); let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist); let params = (&config, &whitelist);
add_benchmarks!(params, batches);
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches) Ok(batches)
......
...@@ -802,6 +802,26 @@ impl frame_support::traits::OnRuntimeUpgrade for UniquesV1Migration { ...@@ -802,6 +802,26 @@ impl frame_support::traits::OnRuntimeUpgrade for UniquesV1Migration {
} }
} }
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_session, SessionBench::<Runtime>]
[pallet_uniques, Uniques]
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
[pallet_collator_selection, CollatorSelection]
);
}
impl_runtime_apis! { impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration { fn slot_duration() -> sp_consensus_aura::SlotDuration {
...@@ -928,33 +948,22 @@ impl_runtime_apis! { ...@@ -928,33 +948,22 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>, Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>, Vec<frame_support::traits::StorageInfo>,
) { ) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait; use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
let mut list = Vec::<BenchmarkList>::new(); let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
list_benchmark!(list, extra, pallet_assets, Assets);
list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_multisig, Multisig);
list_benchmark!(list, extra, pallet_proxy, Proxy);
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
list_benchmark!(list, extra, pallet_uniques, Uniques);
list_benchmark!(list, extra, pallet_utility, Utility);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);
let storage_info = AllPalletsWithSystem::storage_info(); let storage_info = AllPalletsWithSystem::storage_info();
return (list, storage_info) return (list, storage_info)
} }
fn dispatch_benchmark( fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> { ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {}
...@@ -977,17 +986,7 @@ impl_runtime_apis! { ...@@ -977,17 +986,7 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new(); let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist); let params = (&config, &whitelist);
add_benchmarks!(params, batches);
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_multisig, Multisig);
add_benchmark!(params, batches, pallet_proxy, Proxy);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_uniques, Uniques);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches) Ok(batches)
......
...@@ -797,6 +797,26 @@ pub type Executive = frame_executive::Executive< ...@@ -797,6 +797,26 @@ pub type Executive = frame_executive::Executive<
AllPalletsWithSystem, AllPalletsWithSystem,
>; >;
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_session, SessionBench::<Runtime>]
[pallet_uniques, Uniques]
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
[pallet_collator_selection, CollatorSelection]
);
}
impl_runtime_apis! { impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration { fn slot_duration() -> sp_consensus_aura::SlotDuration {
...@@ -923,33 +943,22 @@ impl_runtime_apis! { ...@@ -923,33 +943,22 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>, Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>, Vec<frame_support::traits::StorageInfo>,
) { ) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait; use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
let mut list = Vec::<BenchmarkList>::new(); let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
list_benchmark!(list, extra, pallet_assets, Assets);
list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_multisig, Multisig);
list_benchmark!(list, extra, pallet_proxy, Proxy);
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
list_benchmark!(list, extra, pallet_uniques, Uniques);
list_benchmark!(list, extra, pallet_utility, Utility);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);
let storage_info = AllPalletsWithSystem::storage_info(); let storage_info = AllPalletsWithSystem::storage_info();
return (list, storage_info) return (list, storage_info)
} }
fn dispatch_benchmark( fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> { ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {}
...@@ -972,17 +981,7 @@ impl_runtime_apis! { ...@@ -972,17 +981,7 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new(); let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist); let params = (&config, &whitelist);
add_benchmarks!(params, batches);
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_multisig, Multisig);
add_benchmark!(params, batches, pallet_proxy, Proxy);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_uniques, Uniques);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches) Ok(batches)
......
...@@ -780,6 +780,26 @@ impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip { ...@@ -780,6 +780,26 @@ impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
} }
} }
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_session, SessionBench::<Runtime>]
[pallet_uniques, Uniques]
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
[pallet_collator_selection, CollatorSelection]
);
}
impl_runtime_apis! { impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime { impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration { fn slot_duration() -> sp_consensus_aura::SlotDuration {
...@@ -906,33 +926,22 @@ impl_runtime_apis! { ...@@ -906,33 +926,22 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkList>, Vec<frame_benchmarking::BenchmarkList>,
Vec<frame_support::traits::StorageInfo>, Vec<frame_support::traits::StorageInfo>,
) { ) {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait; use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
let mut list = Vec::<BenchmarkList>::new(); let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
list_benchmark!(list, extra, frame_system, SystemBench::<Runtime>);
list_benchmark!(list, extra, pallet_assets, Assets);
list_benchmark!(list, extra, pallet_balances, Balances);
list_benchmark!(list, extra, pallet_multisig, Multisig);
list_benchmark!(list, extra, pallet_proxy, Proxy);
list_benchmark!(list, extra, pallet_session, SessionBench::<Runtime>);
list_benchmark!(list, extra, pallet_uniques, Uniques);
list_benchmark!(list, extra, pallet_utility, Utility);
list_benchmark!(list, extra, pallet_timestamp, Timestamp);
list_benchmark!(list, extra, pallet_collator_selection, CollatorSelection);
let storage_info = AllPalletsWithSystem::storage_info(); let storage_info = AllPalletsWithSystem::storage_info();
return (list, storage_info) return (list, storage_info)
} }
fn dispatch_benchmark( fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> { ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
use frame_system_benchmarking::Pallet as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {}
...@@ -955,17 +964,7 @@ impl_runtime_apis! { ...@@ -955,17 +964,7 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new(); let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist); let params = (&config, &whitelist);
add_benchmarks!(params, batches);
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_multisig, Multisig);
add_benchmark!(params, batches, pallet_proxy, Proxy);
add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
add_benchmark!(params, batches, pallet_uniques, Uniques);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_collator_selection, CollatorSelection);
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches) Ok(batches)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment