mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 18:01:04 +00:00
Constant Weight Signature in Benchmarking CLI (#7233)
* Don't remove unused components * add more metadata to generated file * unused code * proposed format * Revert "proposed format" This reverts commit ce522c3480157ab6670bcbd9b17e1398168cabf4. * Update weight signatures and unused components in benchmarks * Keep timestamp constant time * remove component from as_derivative
This commit is contained in:
@@ -61,7 +61,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
set_changes_trie_config {
|
||||
let d in 0 .. 1000;
|
||||
let d = 1000;
|
||||
|
||||
let digest_item = DigestItemOf::<T>::Other(vec![]);
|
||||
|
||||
|
||||
@@ -22,15 +22,13 @@
|
||||
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
|
||||
|
||||
impl crate::WeightInfo for () {
|
||||
// WARNING! Some components were not used: ["b"]
|
||||
fn remark() -> Weight {
|
||||
fn remark(_b: u32) -> Weight {
|
||||
(1305000 as Weight)
|
||||
}
|
||||
fn set_heap_pages() -> Weight {
|
||||
(2023000 as Weight)
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// WARNING! Some components were not used: ["d"]
|
||||
fn set_changes_trie_config() -> Weight {
|
||||
(10026000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
|
||||
@@ -160,7 +160,7 @@ pub fn extrinsics_data_root<H: Hash>(xts: Vec<Vec<u8>>) -> H::Output {
|
||||
}
|
||||
|
||||
pub trait WeightInfo {
|
||||
fn remark() -> Weight;
|
||||
fn remark(b: u32) -> Weight;
|
||||
fn set_heap_pages() -> Weight;
|
||||
fn set_changes_trie_config() -> Weight;
|
||||
fn set_storage(i: u32, ) -> Weight;
|
||||
@@ -570,7 +570,7 @@ decl_module! {
|
||||
/// - Base Weight: 0.665 µs, independent of remark length.
|
||||
/// - No DB operations.
|
||||
/// # </weight>
|
||||
#[weight = T::SystemWeightInfo::remark()]
|
||||
#[weight = T::SystemWeightInfo::remark(_remark.len() as u32)]
|
||||
fn remark(origin, _remark: Vec<u8>) {
|
||||
ensure_signed(origin)?;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ benchmarks! {
|
||||
_ { }
|
||||
|
||||
set {
|
||||
let t in 1 .. MAX_TIME;
|
||||
let t = MAX_TIME;
|
||||
// Ignore write to `DidUpdate` since it transient.
|
||||
let did_update_key = crate::DidUpdate::hashed_key().to_vec();
|
||||
frame_benchmarking::benchmarking::add_to_whitelist(TrackedStorageKey {
|
||||
@@ -47,7 +47,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
on_finalize {
|
||||
let t in 1 .. MAX_TIME;
|
||||
let t = MAX_TIME;
|
||||
Timestamp::<T>::set(RawOrigin::None.into(), t.into())?;
|
||||
ensure!(DidUpdate::exists(), "Time was not set.");
|
||||
// Ignore read/write to `DidUpdate` since it is transient.
|
||||
|
||||
@@ -22,13 +22,11 @@
|
||||
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
|
||||
|
||||
impl crate::WeightInfo for () {
|
||||
// WARNING! Some components were not used: ["t"]
|
||||
fn set() -> Weight {
|
||||
(9133000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// WARNING! Some components were not used: ["t"]
|
||||
fn on_finalize() -> Weight {
|
||||
(5915000 as Weight)
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ use frame_support::{
|
||||
use sp_runtime::{
|
||||
RuntimeString,
|
||||
traits::{
|
||||
AtLeast32Bit, Zero, SaturatedConversion, Scale
|
||||
AtLeast32Bit, Zero, SaturatedConversion, Scale,
|
||||
}
|
||||
};
|
||||
use frame_system::ensure_none;
|
||||
@@ -159,9 +159,9 @@ decl_module! {
|
||||
/// The dispatch origin for this call must be `Inherent`.
|
||||
///
|
||||
/// # <weight>
|
||||
/// - `O(T)` where `T` complexity of `on_timestamp_set`
|
||||
/// - `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`)
|
||||
/// - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`)
|
||||
/// - 1 event handler `on_timestamp_set` `O(T)`.
|
||||
/// - 1 event handler `on_timestamp_set`. Must be `O(1)`.
|
||||
/// # </weight>
|
||||
#[weight = (
|
||||
T::WeightInfo::set(),
|
||||
|
||||
@@ -203,7 +203,7 @@ benchmarks_instance! {
|
||||
}: _(RawOrigin::Signed(caller), reason, awesome_person)
|
||||
|
||||
retract_tip {
|
||||
let r in 0 .. MAX_BYTES;
|
||||
let r = MAX_BYTES;
|
||||
let (caller, reason, awesome_person) = setup_awesome::<T, _>(r);
|
||||
Treasury::<T, _>::report_awesome(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
|
||||
@@ -44,7 +44,6 @@ impl crate::WeightInfo for () {
|
||||
.saturating_add(DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// WARNING! Some components were not used: ["r"]
|
||||
fn retract_tip() -> Weight {
|
||||
(82970000 as Weight)
|
||||
.saturating_add(DbWeight::get().reads(1 as Weight))
|
||||
|
||||
@@ -50,13 +50,12 @@ benchmarks! {
|
||||
}
|
||||
|
||||
as_derivative {
|
||||
let u in 0 .. 1000;
|
||||
let caller = account("caller", u, SEED);
|
||||
let caller = account("caller", SEED, SEED);
|
||||
let call = Box::new(frame_system::Call::remark(vec![]).into());
|
||||
// Whitelist caller account from further DB operations.
|
||||
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
|
||||
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
|
||||
}: _(RawOrigin::Signed(caller), u as u16, call)
|
||||
}: _(RawOrigin::Signed(caller), SEED as u16, call)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -27,7 +27,6 @@ impl crate::WeightInfo for () {
|
||||
(16461000 as Weight)
|
||||
.saturating_add((1982000 as Weight).saturating_mul(c as Weight))
|
||||
}
|
||||
// WARNING! Some components were not used: ["u"]
|
||||
fn as_derivative() -> Weight {
|
||||
(4086000 as Weight)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user