93
93
#![ cfg_attr( not( feature = "std" ) , no_std) ]
94
94
95
95
mod benchmarking;
96
+ mod default_weights;
96
97
97
98
use sp_std:: { result, cmp} ;
98
99
use sp_inherents:: { ProvideInherent , InherentData , InherentIdentifier } ;
@@ -116,13 +117,8 @@ use sp_timestamp::{
116
117
} ;
117
118
118
119
pub trait WeightInfo {
119
- fn set ( t : u32 , ) -> Weight ;
120
- fn on_finalize ( t : u32 , ) -> Weight ;
121
- }
122
-
123
- impl WeightInfo for ( ) {
124
- fn set ( _t : u32 , ) -> Weight { 1_000_000_000 }
125
- fn on_finalize ( _t : u32 , ) -> Weight { 1_000_000_000 }
120
+ fn set ( ) -> Weight ;
121
+ fn on_finalize ( ) -> Weight ;
126
122
}
127
123
128
124
/// The module configuration trait
@@ -166,12 +162,9 @@ decl_module! {
166
162
/// - `O(T)` where `T` complexity of `on_timestamp_set`
167
163
/// - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`)
168
164
/// - 1 event handler `on_timestamp_set` `O(T)`.
169
- /// - Benchmark: 7.678 (min squares analysis)
170
- /// - NOTE: This benchmark was done for a runtime with insignificant `on_timestamp_set` handlers.
171
- /// New benchmarking is needed when adding new handlers.
172
165
/// # </weight>
173
166
#[ weight = (
174
- T :: DbWeight :: get ( ) . reads_writes ( 2 , 1 ) + 8_000_000 ,
167
+ T :: WeightInfo :: set ( ) ,
175
168
DispatchClass :: Mandatory
176
169
) ]
177
170
fn set( origin, #[ compact] now: T :: Moment ) {
@@ -191,13 +184,12 @@ decl_module! {
191
184
/// dummy `on_initialize` to return the weight used in `on_finalize`.
192
185
fn on_initialize( ) -> Weight {
193
186
// weight of `on_finalize`
194
- 5_000_000
187
+ T :: WeightInfo :: on_finalize ( )
195
188
}
196
189
197
190
/// # <weight>
198
191
/// - `O(1)`
199
192
/// - 1 storage deletion (codec `O(1)`).
200
- /// - Benchmark: 4.928 µs (min squares analysis)
201
193
/// # </weight>
202
194
fn on_finalize( ) {
203
195
assert!( <Self as Store >:: DidUpdate :: take( ) , "Timestamp must be updated once in the block" ) ;
0 commit comments