Skip to content

Commit

Permalink
More Improvements to Benchmarking CLI + Generic WeightInfo (paritytec…
Browse files Browse the repository at this point in the history
…h#7168)

* Generic WeightInfo, Output File Path

* Make `WeightInfo` generic

* Add support for header file

* fix line width

* add `--spaces` flag

* Configurable trait and struct strings

* make elections phragmen generic

* Add date to generated file

* Apply suggestions from code review

Co-authored-by: Gavin Wood <[email protected]>

* fixes

* add settings metadata to output

Co-authored-by: nikvolf <[email protected]>
Co-authored-by: Gavin Wood <[email protected]>
  • Loading branch information
3 people authored Sep 23, 2020
1 parent 38d5bb3 commit 8b412b4
Show file tree
Hide file tree
Showing 25 changed files with 583 additions and 426 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions HEADER
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file is part of Substrate.

// Copyright (C) 2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
36 changes: 18 additions & 18 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ impl frame_system::Trait for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = weights::frame_system::WeightInfo;
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
}

impl pallet_utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type WeightInfo = weights::pallet_utility::WeightInfo;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -207,7 +207,7 @@ impl pallet_multisig::Trait for Runtime {
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = weights::pallet_multisig::WeightInfo;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -271,7 +271,7 @@ impl pallet_proxy::Trait for Runtime {
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type WeightInfo = weights::pallet_proxy::WeightInfo;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
type MaxPending = MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
Expand All @@ -291,7 +291,7 @@ impl pallet_scheduler::Trait for Runtime {
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = weights::pallet_scheduler::WeightInfo;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -331,7 +331,7 @@ impl pallet_indices::Trait for Runtime {
type Currency = Balances;
type Deposit = IndexDeposit;
type Event = Event;
type WeightInfo = weights::pallet_indices::WeightInfo;
type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -348,7 +348,7 @@ impl pallet_balances::Trait for Runtime {
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module<Runtime>;
type WeightInfo = weights::pallet_balances::WeightInfo;
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -375,7 +375,7 @@ impl pallet_timestamp::Trait for Runtime {
type Moment = Moment;
type OnTimestampSet = Babe;
type MinimumPeriod = MinimumPeriod;
type WeightInfo = weights::pallet_timestamp::WeightInfo;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -412,7 +412,7 @@ impl pallet_session::Trait for Runtime {
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
type WeightInfo = weights::pallet_session::WeightInfo;
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
}

impl pallet_session::historical::Trait for Runtime {
Expand Down Expand Up @@ -469,7 +469,7 @@ impl pallet_staking::Trait for Runtime {
type MinSolutionScoreBump = MinSolutionScoreBump;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type UnsignedPriority = StakingUnsignedPriority;
type WeightInfo = weights::pallet_staking::WeightInfo;
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -518,7 +518,7 @@ impl pallet_democracy::Trait for Runtime {
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = weights::pallet_democracy::WeightInfo;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -536,7 +536,7 @@ impl pallet_collective::Trait<CouncilCollective> for Runtime {
type MaxProposals = CouncilMaxProposals;
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = weights::pallet_collective::WeightInfo;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -568,7 +568,7 @@ impl pallet_elections_phragmen::Trait for Runtime {
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo;
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>;
}

parameter_types! {
Expand All @@ -586,7 +586,7 @@ impl pallet_collective::Trait<TechnicalCollective> for Runtime {
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = weights::pallet_collective::WeightInfo;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}

type EnsureRootOrHalfCouncil = EnsureOneOf<
Expand Down Expand Up @@ -654,7 +654,7 @@ impl pallet_treasury::Trait for Runtime {
type BountyValueMinimum = BountyValueMinimum;
type MaximumReasonLength = MaximumReasonLength;
type BurnDestination = ();
type WeightInfo = weights::pallet_treasury::WeightInfo;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -759,7 +759,7 @@ impl pallet_im_online::Trait for Runtime {
type SessionDuration = SessionDuration;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority;
type WeightInfo = weights::pallet_im_online::WeightInfo;
type WeightInfo = weights::pallet_im_online::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -827,7 +827,7 @@ impl pallet_identity::Trait for Runtime {
type Slashed = Treasury;
type ForceOrigin = EnsureRootOrHalfCouncil;
type RegistrarOrigin = EnsureRootOrHalfCouncil;
type WeightInfo = weights::pallet_identity::WeightInfo;
type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
}

parameter_types! {
Expand Down Expand Up @@ -884,7 +884,7 @@ impl pallet_vesting::Trait for Runtime {
type Currency = Balances;
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = weights::pallet_vesting::WeightInfo;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
}

construct_runtime!(
Expand Down
19 changes: 10 additions & 9 deletions bin/node/runtime/src/weights/frame_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,39 @@
#![allow(unused_parens)]

use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

pub struct WeightInfo;
impl frame_system::WeightInfo for WeightInfo {
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Trait> frame_system::WeightInfo for WeightInfo<T> {
// WARNING! Some components were not used: ["b"]
fn remark() -> Weight {
(1305000 as Weight)
}
fn set_heap_pages() -> Weight {
(2023000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// WARNING! Some components were not used: ["d"]
fn set_changes_trie_config() -> Weight {
(10026000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn set_storage(i: u32, ) -> Weight {
(0 as Weight)
.saturating_add((656000 as Weight).saturating_mul(i as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_storage(i: u32, ) -> Weight {
(4327000 as Weight)
.saturating_add((478000 as Weight).saturating_mul(i as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_prefix(p: u32, ) -> Weight {
(8349000 as Weight)
.saturating_add((838000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight)))
}
fn suicide() -> Weight {
(29247000 as Weight)
Expand Down
6 changes: 3 additions & 3 deletions bin/node/runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
pub mod frame_system;
pub mod pallet_balances;
pub mod pallet_treasury;
pub mod pallet_collective;
pub mod pallet_democracy;
pub mod pallet_elections_phragmen;
pub mod pallet_identity;
pub mod pallet_indices;
pub mod pallet_im_online;
pub mod pallet_indices;
pub mod pallet_multisig;
pub mod pallet_proxy;
pub mod pallet_scheduler;
pub mod pallet_session;
pub mod pallet_staking;
pub mod pallet_timestamp;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod pallet_elections_phragmen;
27 changes: 14 additions & 13 deletions bin/node/runtime/src/weights/pallet_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,34 @@

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

pub struct WeightInfo;
impl pallet_balances::WeightInfo for WeightInfo {
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Trait> pallet_balances::WeightInfo for WeightInfo<T> {
fn transfer() -> Weight {
(65949000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn transfer_keep_alive() -> Weight {
(46665000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_balance_creating() -> Weight {
(27086000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_balance_killing() -> Weight {
(33424000 as Weight)
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn force_transfer() -> Weight {
(65343000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
}
Loading

0 comments on commit 8b412b4

Please sign in to comment.