Refactor weight constants, Update to remove redundant overhead (#5884)

* Move weight values to `frame_support`

* more accurate comment

* update balances

* vesting

* update util

* Add weight to time constants

* use weight constants in weights

* update tests
This commit is contained in:
Shawn Tabrizi
2020-05-04 19:52:53 +02:00
committed by GitHub
parent a00a4ca551
commit 8df33e50af
9 changed files with 87 additions and 66 deletions
+11 -11
View File
@@ -194,11 +194,11 @@ decl_module! {
/// - Reads: Vesting Storage, Balances Locks, [Sender Account]
/// - Writes: Vesting Storage, Balances Locks, [Sender Account]
/// - Benchmark:
/// - Unlocked: 56.1 + .098 * l µs (min square analysis)
/// - Locked: 54.37 + .254 * l µs (min square analysis)
/// - Using 60 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// - Unlocked: 48.76 + .048 * l µs (min square analysis)
/// - Locked: 44.43 + .284 * l µs (min square analysis)
/// - Using 50 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// # </weight>
#[weight = 60_000_000 + T::DbWeight::get().reads_writes(2, 2)]
#[weight = 50_000_000 + T::DbWeight::get().reads_writes(2, 2)]
fn vest(origin) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::update_lock(who)
@@ -219,11 +219,11 @@ decl_module! {
/// - Reads: Vesting Storage, Balances Locks, Target Account
/// - Writes: Vesting Storage, Balances Locks, Target Account
/// - Benchmark:
/// - Unlocked: 58.09 + .104 * l µs (min square analysis)
/// - Locked: 55.35 + .255 * l µs (min square analysis)
/// - Using 60 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// - Unlocked: 44.3 + .294 * l µs (min square analysis)
/// - Locked: 48.16 + .103 * l µs (min square analysis)
/// - Using 50 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// # </weight>
#[weight = 60_000_000 + T::DbWeight::get().reads_writes(3, 3)]
#[weight = 50_000_000 + T::DbWeight::get().reads_writes(3, 3)]
fn vest_other(origin, target: <T::Lookup as StaticLookup>::Source) -> DispatchResult {
ensure_signed(origin)?;
Self::update_lock(T::Lookup::lookup(target)?)
@@ -244,10 +244,10 @@ decl_module! {
/// - DbWeight: 3 Reads, 3 Writes
/// - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
/// - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
/// - Benchmark: 111.4 + .345 * l µs (min square analysis)
/// - Using 115 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// - Benchmark: 100.3 + .365 * l µs (min square analysis)
/// - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
/// # </weight>
#[weight = 115_000_000 + T::DbWeight::get().reads_writes(3, 3)]
#[weight = 100_000_000 + T::DbWeight::get().reads_writes(3, 3)]
pub fn vested_transfer(
origin,
target: <T::Lookup as StaticLookup>::Source,