mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
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:
@@ -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 an empty block.
|
||||
@@ -53,7 +53,8 @@ parameter_types! {
|
||||
/// 99th: 390_723
|
||||
/// 95th: 365_799
|
||||
/// 75th: 361_582
|
||||
pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(358_523);
|
||||
pub const BlockExecutionWeight: Weight =
|
||||
Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(358_523));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -69,12 +70,12 @@ mod test_weights {
|
||||
|
||||
// At least 100 µs.
|
||||
assert!(
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Weight should be at least 100 µs."
|
||||
);
|
||||
// At most 50 ms.
|
||||
assert!(
|
||||
w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Weight should be at most 50 ms."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ pub mod constants {
|
||||
/// ParityDB can be enabled with a feature flag, but is still experimental. These weights
|
||||
/// are available for brave runtime engineers who may want to try this out as default.
|
||||
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(),
|
||||
write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(),
|
||||
read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Read weight should be at least 1 µs."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Write weight should be at least 1 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Read weight should be at most 1 ms."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Write weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ pub mod constants {
|
||||
/// By default, Substrate uses RocksDB, so this will be the weight used throughout
|
||||
/// the runtime.
|
||||
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(),
|
||||
write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(),
|
||||
read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ pub mod constants {
|
||||
fn sane() {
|
||||
// At least 1 µs.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Read weight should be at least 1 µs."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(),
|
||||
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
|
||||
"Write weight should be at least 1 µs."
|
||||
);
|
||||
// At most 1 ms.
|
||||
assert!(
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Read weight should be at most 1 ms."
|
||||
);
|
||||
assert!(
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(),
|
||||
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
|
||||
"Write weight should be at most 1 ms."
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user