Add WeightInfo to all pallets with benchmarks. (#6575)

* Start adding weight info

* More weightinfo

* finish weight info

* more fixes

* inital update of node runtime

* fix the rest of the compilation

* update balances

* add docs

* fix balances tests

* Fix more tests

* Fix compile

* Fix pallet-evm tests
This commit is contained in:
Shawn Tabrizi
2020-07-08 18:22:01 +02:00
committed by GitHub
parent 94cddee160
commit 2302898b8a
65 changed files with 632 additions and 7 deletions
+27
View File
@@ -111,6 +111,30 @@ type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trai
type PositiveImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::PositiveImbalance;
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
pub trait WeightInfo {
fn propose_spend(u: u32, ) -> Weight;
fn reject_proposal(u: u32, ) -> Weight;
fn approve_proposal(u: u32, ) -> Weight;
fn report_awesome(r: u32, ) -> Weight;
fn retract_tip(r: u32, ) -> Weight;
fn tip_new(r: u32, t: u32, ) -> Weight;
fn tip(t: u32, ) -> Weight;
fn close_tip(t: u32, ) -> Weight;
fn on_initialize(p: u32, ) -> Weight;
}
impl WeightInfo for () {
fn propose_spend(_u: u32, ) -> Weight { 1_000_000_000 }
fn reject_proposal(_u: u32, ) -> Weight { 1_000_000_000 }
fn approve_proposal(_u: u32, ) -> Weight { 1_000_000_000 }
fn report_awesome(_r: u32, ) -> Weight { 1_000_000_000 }
fn retract_tip(_r: u32, ) -> Weight { 1_000_000_000 }
fn tip_new(_r: u32, _t: u32, ) -> Weight { 1_000_000_000 }
fn tip(_t: u32, ) -> Weight { 1_000_000_000 }
fn close_tip(_t: u32, ) -> Weight { 1_000_000_000 }
fn on_initialize(_p: u32, ) -> Weight { 1_000_000_000 }
}
pub trait Trait: frame_system::Trait {
/// The treasury's module id, used for deriving its sovereign account ID.
type ModuleId: Get<ModuleId>;
@@ -159,6 +183,9 @@ pub trait Trait: frame_system::Trait {
/// Percentage of spare funds (if any) that are burnt per spend period.
type Burn: Get<Permill>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
/// An index of a proposal. Just a `u32`.
+3
View File
@@ -84,6 +84,7 @@ impl frame_system::Trait for Test {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
@@ -94,6 +95,7 @@ impl pallet_balances::Trait for Test {
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
thread_local! {
static TEN_TO_FOURTEEN: RefCell<Vec<u64>> = RefCell::new(vec![10,11,12,13,14]);
@@ -147,6 +149,7 @@ impl Trait for Test {
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type WeightInfo = ();
}
type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;