From 6eff9a0990e0174bac6656ec6d827f84850d58f6 Mon Sep 17 00:00:00 2001 From: zjb0807 <zjb0807@qq.com> Date: Mon, 12 Oct 2020 08:16:38 +0800 Subject: [PATCH] update orml weightinfo (#301) --- auction/src/default_weight.rs | 38 ++++++++++++++++++-------- auction/src/lib.rs | 8 ++++-- authority/src/default_weight.rs | 24 ++++++++++------ authority/src/lib.rs | 5 ++-- currencies/src/default_weight.rs | 38 ++++++++++++++------------ currencies/src/lib.rs | 10 ++++--- gradually-update/src/default_weight.rs | 28 ++++++++----------- gradually-update/src/lib.rs | 8 ++++-- oracle/src/default_weight.rs | 18 +++++++----- oracle/src/lib.rs | 8 +++--- rewards/src/default_weight.rs | 12 ++++++-- rewards/src/lib.rs | 4 +-- tokens/src/default_weight.rs | 23 ++++++++-------- vesting/src/default_weight.rs | 38 +++++++++++++------------- vesting/src/lib.rs | 9 +++--- 15 files changed, 153 insertions(+), 118 deletions(-) diff --git a/auction/src/default_weight.rs b/auction/src/default_weight.rs index 7628712..8ba27da 100644 --- a/auction/src/default_weight.rs +++ b/auction/src/default_weight.rs @@ -1,18 +1,32 @@ -//! Weights for the Auction Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 -use frame_support::weights::{ - constants::{RocksDbWeight as DbWeight, WEIGHT_PER_MICROS}, - Weight, -}; +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { - fn bid() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(300) - .saturating_add(DbWeight::get().reads_writes(14, 14)) + fn bid_collateral_auction() -> Weight { + (493_957_000 as Weight) + .saturating_add(DbWeight::get().reads(12 as Weight)) + .saturating_add(DbWeight::get().writes(12 as Weight)) } - - fn on_finalize(_a: u32) -> Weight { - 0 + fn bid_surplus_auction() -> Weight { + (257_830_000 as Weight) + .saturating_add(DbWeight::get().reads(6 as Weight)) + .saturating_add(DbWeight::get().writes(5 as Weight)) + } + fn bid_debit_auction() -> Weight { + (287_271_000 as Weight) + .saturating_add(DbWeight::get().reads(7 as Weight)) + .saturating_add(DbWeight::get().writes(8 as Weight)) + } + fn on_finalize(c: u32) -> Weight { + (50_992_000 as Weight) + .saturating_add((171_653_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(DbWeight::get().reads(3 as Weight)) + .saturating_add(DbWeight::get().reads((4 as Weight).saturating_mul(c as Weight))) + .saturating_add(DbWeight::get().writes(2 as Weight)) + .saturating_add(DbWeight::get().writes((3 as Weight).saturating_mul(c as Weight))) } } diff --git a/auction/src/lib.rs b/auction/src/lib.rs index 0401587..bf14156 100644 --- a/auction/src/lib.rs +++ b/auction/src/lib.rs @@ -28,8 +28,10 @@ mod mock; mod tests; pub trait WeightInfo { - fn bid() -> Weight; - fn on_finalize(a: u32) -> Weight; + fn bid_collateral_auction() -> Weight; + fn bid_surplus_auction() -> Weight; + fn bid_debit_auction() -> Weight; + fn on_finalize(c: u32) -> Weight; } pub trait Trait: frame_system::Trait { @@ -120,7 +122,7 @@ decl_module! { /// - best cases: 140.7 碌s /// - worst cases: 142.8 碌s /// # </weight> - #[weight = T::WeightInfo::bid()] + #[weight = T::WeightInfo::bid_collateral_auction()] pub fn bid(origin, id: T::AuctionId, #[compact] value: T::Balance) { let from = ensure_signed(origin)?; diff --git a/authority/src/default_weight.rs b/authority/src/default_weight.rs index e205b30..db8e5af 100644 --- a/authority/src/default_weight.rs +++ b/authority/src/default_weight.rs @@ -1,26 +1,32 @@ -//! Weights for the authority Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 + +#![allow(unused_parens)] +#![allow(unused_imports)] use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { fn dispatch_as() -> Weight { - 50750000 as Weight + (43_132_000 as Weight) + } + fn schedule_dispatch_without_delay() -> Weight { + (123_715_000 as Weight) + .saturating_add(DbWeight::get().reads(3 as Weight)) + .saturating_add(DbWeight::get().writes(3 as Weight)) } - fn schedule_dispatch() -> Weight { - (147800000 as Weight) + fn schedule_dispatch_with_delay() -> Weight { + (116_719_000 as Weight) .saturating_add(DbWeight::get().reads(3 as Weight)) .saturating_add(DbWeight::get().writes(3 as Weight)) } fn fast_track_scheduled_dispatch() -> Weight { - // TODO - 0 as Weight + (59_055_000 as Weight) } fn delay_scheduled_dispatch() -> Weight { - // TODO - 0 as Weight + (44_796_000 as Weight) } fn cancel_scheduled_dispatch() -> Weight { - (127400000 as Weight) + (140_123_000 as Weight) .saturating_add(DbWeight::get().reads(2 as Weight)) .saturating_add(DbWeight::get().writes(2 as Weight)) } diff --git a/authority/src/lib.rs b/authority/src/lib.rs index 119242e..babd636 100644 --- a/authority/src/lib.rs +++ b/authority/src/lib.rs @@ -42,7 +42,8 @@ mod tests; pub trait WeightInfo { fn dispatch_as() -> Weight; - fn schedule_dispatch() -> Weight; + fn schedule_dispatch_without_delay() -> Weight; + fn schedule_dispatch_with_delay() -> Weight; fn fast_track_scheduled_dispatch() -> Weight; fn delay_scheduled_dispatch() -> Weight; fn cancel_scheduled_dispatch() -> Weight; @@ -216,7 +217,7 @@ decl_module! { /// Schedule a dispatchable to be dispatched at later block. /// This is the only way to dispatch a call with `DelayedOrigin`. - #[weight = T::WeightInfo::schedule_dispatch()] + #[weight = T::WeightInfo::schedule_dispatch_without_delay()] pub fn schedule_dispatch( origin, when: DispatchTime<T::BlockNumber>, diff --git a/currencies/src/default_weight.rs b/currencies/src/default_weight.rs index 581e597..a8ff56c 100644 --- a/currencies/src/default_weight.rs +++ b/currencies/src/default_weight.rs @@ -1,26 +1,28 @@ -//! Weights for the Currencies Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 -use frame_support::weights::{ - constants::{RocksDbWeight as DbWeight, WEIGHT_PER_MICROS}, - Weight, -}; +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { - fn transfer() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(90) - .saturating_add(DbWeight::get().reads_writes(5, 2)) + fn transfer_non_native_currency() -> Weight { + (172_011_000 as Weight) + .saturating_add(DbWeight::get().reads(5 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) } - fn transfer_native_currency() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(70) - .saturating_add(DbWeight::get().reads_writes(2, 2)) + (43_023_000 as Weight) } - - fn update_balance() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(66) - .saturating_add(DbWeight::get().reads_writes(5, 2)) + fn update_balance_non_native_currency() -> Weight { + (137_440_000 as Weight) + .saturating_add(DbWeight::get().reads(5 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) + } + fn update_balance_native_currency_creating() -> Weight { + (64_432_000 as Weight) + } + fn update_balance_native_currency_killing() -> Weight { + (62_595_000 as Weight) } } diff --git a/currencies/src/lib.rs b/currencies/src/lib.rs index c471da6..b83140d 100644 --- a/currencies/src/lib.rs +++ b/currencies/src/lib.rs @@ -69,9 +69,11 @@ mod mock; mod tests; pub trait WeightInfo { - fn transfer() -> Weight; + fn transfer_non_native_currency() -> Weight; fn transfer_native_currency() -> Weight; - fn update_balance() -> Weight; + fn update_balance_non_native_currency() -> Weight; + fn update_balance_native_currency_creating() -> Weight; + fn update_balance_native_currency_killing() -> Weight; } type BalanceOf<T> = <<T as Trait>::MultiCurrency as MultiCurrency<<T as frame_system::Trait>::AccountId>>::Balance; @@ -151,7 +153,7 @@ decl_module! { /// - non-native currency: 90.23 碌s /// - native currency in worst case: 70 碌s /// # </weight> - #[weight = T::WeightInfo::transfer()] + #[weight = T::WeightInfo::transfer_non_native_currency()] pub fn transfer( origin, dest: <T::Lookup as StaticLookup>::Source, @@ -209,7 +211,7 @@ decl_module! { /// - native currency and killing account: 26.33 碌s /// - native currency and create account: 27.39 碌s /// # </weight> - #[weight = T::WeightInfo::transfer_native_currency()] + #[weight = T::WeightInfo::update_balance_non_native_currency()] pub fn update_balance( origin, who: <T::Lookup as StaticLookup>::Source, diff --git a/gradually-update/src/default_weight.rs b/gradually-update/src/default_weight.rs index 03a956c..53b6b68 100644 --- a/gradually-update/src/default_weight.rs +++ b/gradually-update/src/default_weight.rs @@ -1,31 +1,25 @@ -//! Weights for the Gradually-update Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 + +#![allow(unused_parens)] +#![allow(unused_imports)] use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { fn gradually_update() -> Weight { - (82320000 as Weight) + (57_922_000 as Weight) .saturating_add(DbWeight::get().reads(2 as Weight)) .saturating_add(DbWeight::get().writes(1 as Weight)) } fn cancel_gradually_update() -> Weight { - (72950000 as Weight) + (66_687_000 as Weight) .saturating_add(DbWeight::get().reads(1 as Weight)) .saturating_add(DbWeight::get().writes(1 as Weight)) } - fn on_initialize(need_update: bool, update_len: usize) -> Weight { - if !need_update { - return 0; - } - - if update_len == 0 { - (30430000 as Weight) - .saturating_add(DbWeight::get().reads(2 as Weight)) - .saturating_add(DbWeight::get().writes(1 as Weight)) - } else { - (91390000 + (30000000 * update_len) as Weight) - .saturating_add(DbWeight::get().reads(3 as Weight)) - .saturating_add(DbWeight::get().writes(3 as Weight)) - } + fn on_finalize(u: u32) -> Weight { + (37_067_000 as Weight) + .saturating_add((20_890_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(DbWeight::get().reads(3 as Weight)) + .saturating_add(DbWeight::get().writes(3 as Weight)) } } diff --git a/gradually-update/src/lib.rs b/gradually-update/src/lib.rs index 7c9a088..616558a 100644 --- a/gradually-update/src/lib.rs +++ b/gradually-update/src/lib.rs @@ -38,7 +38,7 @@ mod tests; pub trait WeightInfo { fn gradually_update() -> Weight; fn cancel_gradually_update() -> Weight; - fn on_initialize(need_update: bool, update_len: usize) -> Weight; + fn on_finalize(u: u32) -> Weight; } type StorageKey = Vec<u8>; @@ -155,7 +155,11 @@ decl_module! { /// `on_initialize` to return the weight used in `on_finalize`. fn on_initialize() -> Weight { let now = <frame_system::Module<T>>::block_number(); - T::WeightInfo::on_initialize(Self::_need_update(now), GraduallyUpdates::get().len()) + if Self::_need_update(now) { + T::WeightInfo::on_finalize(GraduallyUpdates::get().len() as u32) + } else { + 0 + } } /// Update gradually_update to adjust numeric parameter. diff --git a/oracle/src/default_weight.rs b/oracle/src/default_weight.rs index a020f46..dd88c48 100644 --- a/oracle/src/default_weight.rs +++ b/oracle/src/default_weight.rs @@ -1,15 +1,19 @@ -//! Weights for the Auction Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 + +#![allow(unused_parens)] +#![allow(unused_imports)] use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { - fn feed_values(values_len: usize) -> Weight { - (101600000 as Weight) + fn feed_values(c: u32) -> Weight { + (74_792_000 as Weight) + .saturating_add((11_208_000 as Weight).saturating_mul(c as Weight)) .saturating_add(DbWeight::get().reads(3 as Weight)) - .saturating_add(DbWeight::get().writes((1 + values_len * 2) as Weight)) + .saturating_add(DbWeight::get().writes(1 as Weight)) + .saturating_add(DbWeight::get().writes((2 as Weight).saturating_mul(c as Weight))) } - - fn on_initialize() -> Weight { - (18400000 as Weight).saturating_add(DbWeight::get().writes(1) as Weight) + fn on_finalize() -> Weight { + (15_881_000 as Weight).saturating_add(DbWeight::get().writes(1 as Weight)) } } diff --git a/oracle/src/lib.rs b/oracle/src/lib.rs index 017c898..6a039ff 100644 --- a/oracle/src/lib.rs +++ b/oracle/src/lib.rs @@ -25,8 +25,8 @@ mod mock; mod tests; pub trait WeightInfo { - fn feed_values(n: usize) -> Weight; - fn on_initialize() -> Weight; + fn feed_values(c: u32) -> Weight; + fn on_finalize() -> Weight; } use codec::{Decode, Encode}; @@ -139,7 +139,7 @@ decl_module! { /// Feed the external value. /// /// Require unsigned. However a valid signature signed by session key is required along with payload. - #[weight = (T::WeightInfo::feed_values(values.len()), DispatchClass::Operational)] + #[weight = (T::WeightInfo::feed_values(values.len() as u32), DispatchClass::Operational)] pub fn feed_values( origin, values: Vec<(T::OracleKey, T::OracleValue)>, @@ -151,7 +151,7 @@ decl_module! { /// `on_initialize` to return the weight used in `on_finalize`. fn on_initialize() -> Weight { - T::WeightInfo::on_initialize() + T::WeightInfo::on_finalize() } fn on_finalize(_n: T::BlockNumber) { diff --git a/rewards/src/default_weight.rs b/rewards/src/default_weight.rs index 625e234..51c60f6 100644 --- a/rewards/src/default_weight.rs +++ b/rewards/src/default_weight.rs @@ -1,9 +1,15 @@ -//! Weights for the Rewards Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 + +#![allow(unused_parens)] +#![allow(unused_imports)] use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { - fn on_initialize() -> Weight { - (20100000 as Weight).saturating_add(DbWeight::get().reads(1 as Weight)) + fn on_initialize(c: u32) -> Weight { + (33_360_000 as Weight) + .saturating_add((23_139_000 as Weight).saturating_mul(c as Weight)) + .saturating_add(DbWeight::get().reads(2 as Weight)) + .saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) } } diff --git a/rewards/src/lib.rs b/rewards/src/lib.rs index d4e09e2..44dc305 100644 --- a/rewards/src/lib.rs +++ b/rewards/src/lib.rs @@ -17,7 +17,7 @@ mod mock; mod tests; pub trait WeightInfo { - fn on_initialize() -> Weight; + fn on_initialize(c: u32) -> Weight; } /// The Reward Pool Info. @@ -90,7 +90,7 @@ decl_module! { Pools::<T>::mutate(pool, | pool_info | pool_info.total_rewards = pool_info.total_rewards.saturating_add(reward_to_accumulate)); } }); - T::WeightInfo::on_initialize() + T::WeightInfo::on_initialize(Pools::<T>::iter().count() as u32) } } } diff --git a/tokens/src/default_weight.rs b/tokens/src/default_weight.rs index a54d3c2..00aa6d1 100644 --- a/tokens/src/default_weight.rs +++ b/tokens/src/default_weight.rs @@ -1,20 +1,19 @@ -//! Weights for the Tokens Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 -use frame_support::weights::{ - constants::{RocksDbWeight as DbWeight, WEIGHT_PER_MICROS}, - Weight, -}; +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; impl crate::WeightInfo for () { fn transfer() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(84) - .saturating_add(DbWeight::get().reads_writes(4, 2)) + (158_835_000 as Weight) + .saturating_add(DbWeight::get().reads(4 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) } - fn transfer_all() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(88) - .saturating_add(DbWeight::get().reads_writes(4, 2)) + (162_545_000 as Weight) + .saturating_add(DbWeight::get().reads(4 as Weight)) + .saturating_add(DbWeight::get().writes(2 as Weight)) } } diff --git a/vesting/src/default_weight.rs b/vesting/src/default_weight.rs index 8e60969..dc055d8 100644 --- a/vesting/src/default_weight.rs +++ b/vesting/src/default_weight.rs @@ -1,26 +1,26 @@ -//! Weights for the Vesting Module +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 -use frame_support::weights::{ - constants::{RocksDbWeight as DbWeight, WEIGHT_PER_MICROS}, - Weight, -}; +#![allow(unused_parens)] +#![allow(unused_imports)] -impl crate::WeightInfo for () { - fn claim() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(30) - .saturating_add(DbWeight::get().reads_writes(4, 4)) - } +use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight}; +impl crate::WeightInfo for () { fn vested_transfer() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(150) - .saturating_add(DbWeight::get().reads_writes(3, 3)) + (310_862_000 as Weight) + .saturating_add(DbWeight::get().reads(4 as Weight)) + .saturating_add(DbWeight::get().writes(4 as Weight)) } - - fn update_vesting_schedules() -> Weight { - WEIGHT_PER_MICROS - .saturating_mul(62) - .saturating_add(DbWeight::get().reads_writes(2, 3)) + fn claim(i: u32) -> Weight { + (158_614_000 as Weight) + .saturating_add((958_000 as Weight).saturating_mul(i as Weight)) + .saturating_add(DbWeight::get().reads(3 as Weight)) + .saturating_add(DbWeight::get().writes(3 as Weight)) + } + fn update_vesting_schedules(i: u32) -> Weight { + (119_811_000 as Weight) + .saturating_add((2_320_000 as Weight).saturating_mul(i as Weight)) + .saturating_add(DbWeight::get().reads(2 as Weight)) + .saturating_add(DbWeight::get().writes(3 as Weight)) } } diff --git a/vesting/src/lib.rs b/vesting/src/lib.rs index f6e015a..dd220da 100644 --- a/vesting/src/lib.rs +++ b/vesting/src/lib.rs @@ -48,9 +48,9 @@ mod mock; mod tests; pub trait WeightInfo { - fn claim() -> Weight; fn vested_transfer() -> Weight; - fn update_vesting_schedules() -> Weight; + fn claim(i: u32) -> Weight; + fn update_vesting_schedules(i: u32) -> Weight; } /// The maximum number of vesting schedules an account can have. @@ -201,7 +201,8 @@ decl_module! { /// ------------------- /// Base Weight: 65.23 碌s /// # </weight> - #[weight = T::WeightInfo::claim()] + // can not get VestingSchedule count from `who`, so use `MAX_VESTINGS / 2` + #[weight = T::WeightInfo::claim((MAX_VESTINGS / 2) as u32)] pub fn claim(origin) { let who = ensure_signed(origin)?; let locked_amount = Self::do_claim(&who); @@ -240,7 +241,7 @@ decl_module! { /// ------------------- /// Base Weight: 61.87 碌s /// # </weight> - #[weight = T::WeightInfo::update_vesting_schedules()] + #[weight = T::WeightInfo::update_vesting_schedules(vesting_schedules.len() as u32)] pub fn update_vesting_schedules( origin, who: <T::Lookup as StaticLookup>::Source, -- GitLab