@@ -87,7 +87,7 @@ pub enum Warning {
8787 #[ error( "clear prefix without limit, cannot be tracked" ) ]
8888 ClearPrefixWithoutLimit ,
8989 #[ error( "child storage is not supported" ) ]
90- ChildStorageNoSupported ,
90+ ChildStorageNotSupported ,
9191}
9292
9393pub struct BenchTracker {
@@ -99,6 +99,7 @@ pub struct BenchTracker {
9999 clear_prefixes : RwLock < HashMap < StorageKey , u32 > > ,
100100 warnings : RwLock < Vec < Warning > > ,
101101 whitelisted_keys : RwLock < HashMap < StorageKey , ( bool , bool ) > > ,
102+ count_clear_prefix : RwLock < bool > ,
102103}
103104
104105impl BenchTracker {
@@ -112,6 +113,7 @@ impl BenchTracker {
112113 clear_prefixes : RwLock :: new ( HashMap :: new ( ) ) ,
113114 warnings : RwLock :: new ( Vec :: new ( ) ) ,
114115 whitelisted_keys : RwLock :: new ( HashMap :: new ( ) ) ,
116+ count_clear_prefix : RwLock :: new ( false ) ,
115117 }
116118 }
117119
@@ -152,7 +154,10 @@ impl BenchTracker {
152154 }
153155
154156 pub fn on_read_child_storage ( & self , _child_info : & ChildInfo , _key : StorageKey ) {
155- self . warn ( Warning :: ChildStorageNoSupported ) ;
157+ if self . is_redundant ( ) {
158+ return ;
159+ }
160+ self . warn ( Warning :: ChildStorageNotSupported ) ;
156161 }
157162
158163 pub fn on_update_storage ( & self , key : StorageKey ) {
@@ -172,11 +177,14 @@ impl BenchTracker {
172177 }
173178
174179 pub fn on_update_child_storage ( & self , _child_info : & ChildInfo , _key : StorageKey ) {
175- self . warn ( Warning :: ChildStorageNoSupported ) ;
180+ if self . is_redundant ( ) {
181+ return ;
182+ }
183+ self . warn ( Warning :: ChildStorageNotSupported ) ;
176184 }
177185
178186 pub fn on_clear_prefix ( & self , prefix : & [ u8 ] , limit : Option < u32 > ) {
179- if self . is_redundant ( ) {
187+ if self . is_redundant ( ) || ! ( * self . count_clear_prefix . read ( ) ) {
180188 return ;
181189 }
182190 if let Some ( limit) = limit {
@@ -196,11 +204,17 @@ impl BenchTracker {
196204 }
197205
198206 pub fn on_clear_child_prefix ( & self , _child_info : & ChildInfo , _prefix : & [ u8 ] , _limit : Option < u32 > ) {
199- self . warn ( Warning :: ChildStorageNoSupported ) ;
207+ if self . is_redundant ( ) {
208+ return ;
209+ }
210+ self . warn ( Warning :: ChildStorageNotSupported ) ;
200211 }
201212
202213 pub fn on_kill_child_storage ( & self , _child_info : & ChildInfo , _limit : Option < u32 > ) {
203- self . warn ( Warning :: ChildStorageNoSupported ) ;
214+ if self . is_redundant ( ) {
215+ return ;
216+ }
217+ self . warn ( Warning :: ChildStorageNotSupported ) ;
204218 }
205219
206220 /// Get the benchmark summary
@@ -325,6 +339,10 @@ impl BenchTracker {
325339 whitelisted. insert ( key, ( read, write) ) ;
326340 }
327341
342+ pub fn count_clear_prefix ( & self ) {
343+ * self . count_clear_prefix . write ( ) = true ;
344+ }
345+
328346 /// Reset for the next benchmark
329347 pub fn reset ( & self ) {
330348 * self . depth . write ( ) = 0 ;
@@ -334,6 +352,7 @@ impl BenchTracker {
334352 self . clear_prefixes . write ( ) . clear ( ) ;
335353 self . warnings . write ( ) . clear ( ) ;
336354 self . whitelisted_keys . write ( ) . clear ( ) ;
355+ * self . count_clear_prefix . write ( ) = false ;
337356 }
338357}
339358
0 commit comments