Use define_benchmarks! (#4760)

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-01-21 18:12:45 +01:00
committed by GitHub
parent 8756678a83
commit cc1201ef27
7 changed files with 219 additions and 277 deletions
+17 -13
View File
@@ -573,6 +573,19 @@ pub type Executive = frame_executive::Executive<
AllPallets,
>;
#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
[pallet_bridge_messages,
MessagesBench::<Runtime, WithMillauMessagesInstance>]
[pallet_bridge_grandpa, BridgeMillauGrandpa]
);
}
impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
@@ -947,18 +960,15 @@ 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_bridge_messages::benchmarking::Pallet as MessagesBench;
let mut list = Vec::<BenchmarkList>::new();
list_benchmark!(list, extra, pallet_bridge_messages, MessagesBench::<Runtime, WithMillauMessagesInstance>);
list_benchmark!(list, extra, pallet_bridge_grandpa, BridgeMillauGrandpa);
list_benchmarks!(list, extra);
let storage_info = AllPalletsWithSystem::storage_info();
return (list, storage_info)
}
@@ -968,7 +978,7 @@ impl_runtime_apis! {
Vec<frame_benchmarking::BenchmarkBatch>,
sp_runtime::RuntimeString,
> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
use frame_support::traits::StorageInfoTrait;
let whitelist: Vec<TrackedStorageKey> = vec![
@@ -1153,13 +1163,7 @@ impl_runtime_apis! {
}
}
add_benchmark!(
params,
batches,
pallet_bridge_messages,
MessagesBench::<Runtime, WithMillauMessagesInstance>
);
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeMillauGrandpa);
add_benchmarks!(params, batches);
Ok(batches)
}