Skip to content

Commit 0c2e48e

Browse files
authored
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
1 parent 4a7538b commit 0c2e48e

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/benchmarking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ benchmarks! {
3333
_ { }
3434

3535
set {
36-
let t in 1 .. MAX_TIME;
36+
let t = MAX_TIME;
3737
// Ignore write to `DidUpdate` since it transient.
3838
let did_update_key = crate::DidUpdate::hashed_key().to_vec();
3939
frame_benchmarking::benchmarking::add_to_whitelist(TrackedStorageKey {
@@ -47,7 +47,7 @@ benchmarks! {
4747
}
4848

4949
on_finalize {
50-
let t in 1 .. MAX_TIME;
50+
let t = MAX_TIME;
5151
Timestamp::<T>::set(RawOrigin::None.into(), t.into())?;
5252
ensure!(DidUpdate::exists(), "Time was not set.");
5353
// Ignore read/write to `DidUpdate` since it is transient.

src/default_weights.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
2323

2424
impl crate::WeightInfo for () {
25-
// WARNING! Some components were not used: ["t"]
2625
fn set() -> Weight {
2726
(9133000 as Weight)
2827
.saturating_add(DbWeight::get().reads(2 as Weight))
2928
.saturating_add(DbWeight::get().writes(1 as Weight))
3029
}
31-
// WARNING! Some components were not used: ["t"]
3230
fn on_finalize() -> Weight {
3331
(5915000 as Weight)
3432
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ use frame_support::{
107107
use sp_runtime::{
108108
RuntimeString,
109109
traits::{
110-
AtLeast32Bit, Zero, SaturatedConversion, Scale
110+
AtLeast32Bit, Zero, SaturatedConversion, Scale,
111111
}
112112
};
113113
use frame_system::ensure_none;
@@ -159,9 +159,9 @@ decl_module! {
159159
/// The dispatch origin for this call must be `Inherent`.
160160
///
161161
/// # <weight>
162-
/// - `O(T)` where `T` complexity of `on_timestamp_set`
162+
/// - `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`)
163163
/// - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`)
164-
/// - 1 event handler `on_timestamp_set` `O(T)`.
164+
/// - 1 event handler `on_timestamp_set`. Must be `O(1)`.
165165
/// # </weight>
166166
#[weight = (
167167
T::WeightInfo::set(),

0 commit comments

Comments
 (0)