Introduce sensible weight constants (#12868)

* Introduce sensible weight constants

* cargo fmt

* Remove unused import

* Add missing import

* ".git/.scripts/bench-bot.sh" pallet dev pallet_lottery

Co-authored-by: command-bot <>
This commit is contained in:
Keith Yeung
2022-12-09 01:18:51 +09:00
committed by GitHub
parent 200f49d66d
commit 51db8c77a7
26 changed files with 140 additions and 113 deletions
@@ -37,7 +37,7 @@
// --repeat=100
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_PER_NANOS, Weight};
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Time to execute a NO-OP extrinsic, for example `System::remark`.
@@ -53,7 +53,8 @@ parameter_types! {
/// 99th: 99_202
/// 95th: 99_163
/// 75th: 99_030
pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(98_974);
pub const ExtrinsicBaseWeight: Weight =
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(98_974));
}
#[cfg(test)]
@@ -69,12 +70,12 @@ mod test_weights {
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(),
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}