@@ -88,24 +88,18 @@ pub use sp_storage::TrackedStorageKey;
8888/// benchmarks! {
8989/// where_clause { where T::A: From<u32> } // Optional line to give additional bound on `T`.
9090///
91- /// // common parameter; just one for this example.
92- /// // will be `1`, `MAX_LENGTH` or any value inbetween
93- /// _ {
94- /// let l in 1 .. MAX_LENGTH => initialize_l(l);
95- /// }
96- ///
9791/// // first dispatchable: foo; this is a user dispatchable and operates on a `u8` vector of
98- /// // size `l`, which we allow to be initialized as usual.
92+ /// // size `l`
9993/// foo {
10094/// let caller = account::<T>(b"caller", 0, benchmarks_seed);
101- /// let l = ... ;
95+ /// let l in 1 .. MAX_LENGTH => initialize_l(l) ;
10296/// }: _(Origin::Signed(caller), vec![0u8; l])
10397///
10498/// // second dispatchable: bar; this is a root dispatchable and accepts a `u8` vector of size
105- /// // `l`. We don't want it pre-initialized like before so we override using the `=> ()` notation.
99+ /// // `l`.
106100/// // In this case, we explicitly name the call using `bar` instead of `_`.
107101/// bar {
108- /// let l = _ .. _ => ( );
102+ /// let l in 1 .. MAX_LENGTH => initialize_l(l );
109103/// }: bar(Origin::Root, vec![0u8; l])
110104///
111105/// // third dispatchable: baz; this is a user dispatchable. It isn't dependent on length like the
@@ -176,18 +170,11 @@ pub use sp_storage::TrackedStorageKey;
176170#[ macro_export]
177171macro_rules! benchmarks {
178172 (
179- $( where_clause { where $( $where_ty: ty: $where_bound: path ) ,* $( , ) ? } ) ?
180- _ {
181- $(
182- let $common: ident in $common_from: tt .. $common_to: expr => $common_instancer: expr;
183- ) *
184- }
185173 $( $rest: tt ) *
186174 ) => {
187175 $crate:: benchmarks_iter!(
188176 { }
189- { $( $( $where_ty: $where_bound ) ,* ) ? }
190- { $( { $common , $common_from , $common_to , $common_instancer } ) * }
177+ { }
191178 ( )
192179 ( )
193180 $( $rest ) *
@@ -199,18 +186,11 @@ macro_rules! benchmarks {
199186#[ macro_export]
200187macro_rules! benchmarks_instance {
201188 (
202- $( where_clause { where $( $where_ty: ty: $where_bound: path ) ,* $( , ) ? } ) ?
203- _ {
204- $(
205- let $common: ident in $common_from: tt .. $common_to: expr => $common_instancer: expr;
206- ) *
207- }
208189 $( $rest: tt ) *
209190 ) => {
210191 $crate:: benchmarks_iter!(
211192 { I }
212- { $( $( $where_ty: $where_bound ) ,* ) ? }
213- { $( { $common , $common_from , $common_to , $common_instancer } ) * }
193+ { }
214194 ( )
215195 ( )
216196 $( $rest ) *
@@ -221,11 +201,27 @@ macro_rules! benchmarks_instance {
221201#[ macro_export]
222202#[ doc( hidden) ]
223203macro_rules! benchmarks_iter {
204+ // detect and extract where clause:
205+ (
206+ { $( $instance: ident ) ? }
207+ { $( $where_clause: tt ) * }
208+ ( $( $names: tt ) * )
209+ ( $( $names_extra: tt ) * )
210+ where_clause { where $( $where_ty: ty: $where_bound: path ) ,* $( , ) ? }
211+ $( $rest: tt ) *
212+ ) => {
213+ $crate:: benchmarks_iter! {
214+ { $( $instance) ? }
215+ { $( $where_ty: $where_bound ) ,* }
216+ ( $( $names ) * )
217+ ( $( $names_extra ) * )
218+ $( $rest ) *
219+ }
220+ } ;
224221 // detect and extract extra tag:
225222 (
226223 { $( $instance: ident ) ? }
227224 { $( $where_clause: tt ) * }
228- { $( $common: tt ) * }
229225 ( $( $names: tt ) * )
230226 ( $( $names_extra: tt ) * )
231227 #[ extra]
@@ -235,7 +231,6 @@ macro_rules! benchmarks_iter {
235231 $crate:: benchmarks_iter! {
236232 { $( $instance) ? }
237233 { $( $where_clause ) * }
238- { $( $common ) * }
239234 ( $( $names ) * )
240235 ( $( $names_extra ) * $name )
241236 $name
@@ -246,7 +241,6 @@ macro_rules! benchmarks_iter {
246241 (
247242 { $( $instance: ident ) ? }
248243 { $( $where_clause: tt ) * }
249- { $( $common: tt ) * }
250244 ( $( $names: tt ) * ) // This contains $( $( { $instance } )? $name:ident )*
251245 ( $( $names_extra: tt ) * )
252246 $name: ident { $( $code: tt ) * } : _ ( $origin: expr $( , $arg: expr ) * )
@@ -256,7 +250,6 @@ macro_rules! benchmarks_iter {
256250 $crate:: benchmarks_iter! {
257251 { $( $instance) ? }
258252 { $( $where_clause ) * }
259- { $( $common ) * }
260253 ( $( $names ) * )
261254 ( $( $names_extra ) * )
262255 $name { $( $code ) * } : $name ( $origin $( , $arg ) * )
@@ -268,7 +261,6 @@ macro_rules! benchmarks_iter {
268261 (
269262 { $( $instance: ident ) ? }
270263 { $( $where_clause: tt ) * }
271- { $( $common: tt ) * }
272264 ( $( $names: tt ) * )
273265 ( $( $names_extra: tt ) * )
274266 $name: ident { $( $code: tt ) * } : $dispatch: ident ( $origin: expr $( , $arg: expr ) * )
@@ -278,7 +270,6 @@ macro_rules! benchmarks_iter {
278270 $crate:: benchmarks_iter! {
279271 { $( $instance) ? }
280272 { $( $where_clause ) * }
281- { $( $common ) * }
282273 ( $( $names ) * )
283274 ( $( $names_extra ) * )
284275 $name { $( $code ) * } : {
@@ -296,7 +287,6 @@ macro_rules! benchmarks_iter {
296287 (
297288 { $( $instance: ident ) ? }
298289 { $( $where_clause: tt ) * }
299- { $( $common: tt ) * }
300290 ( $( $names: tt ) * )
301291 ( $( $names_extra: tt ) * )
302292 $name: ident { $( $code: tt ) * } : $eval: block
@@ -307,7 +297,6 @@ macro_rules! benchmarks_iter {
307297 { $( $instance) ? }
308298 $name
309299 { $( $where_clause ) * }
310- { $( $common ) * }
311300 { }
312301 { $eval }
313302 { $( $code ) * }
@@ -324,7 +313,6 @@ macro_rules! benchmarks_iter {
324313 $crate:: benchmarks_iter!(
325314 { $( $instance) ? }
326315 { $( $where_clause ) * }
327- { $( $common ) * }
328316 ( $( $names ) * { $( $instance ) ? } $name )
329317 ( $( $names_extra ) * )
330318 $( $rest ) *
@@ -334,7 +322,6 @@ macro_rules! benchmarks_iter {
334322 (
335323 { $( $instance: ident ) ? }
336324 { $( $where_clause: tt ) * }
337- { $( $common: tt ) * }
338325 ( $( $names: tt ) * )
339326 ( $( $names_extra: tt ) * )
340327 ) => {
@@ -354,7 +341,6 @@ macro_rules! benchmarks_iter {
354341 (
355342 { $( $instance: ident ) ? }
356343 { $( $where_clause: tt ) * }
357- { $( $common: tt ) * }
358344 ( $( $names: tt ) * )
359345 ( $( $names_extra: tt ) * )
360346 $name: ident { $( $code: tt ) * } : _ ( $origin: expr $( , $arg: expr ) * )
@@ -363,7 +349,6 @@ macro_rules! benchmarks_iter {
363349 $crate:: benchmarks_iter! {
364350 { $( $instance) ? }
365351 { $( $where_clause ) * }
366- { $( $common ) * }
367352 ( $( $names ) * )
368353 ( $( $names_extra ) * )
369354 $name { $( $code ) * } : _ ( $origin $( , $arg ) * )
@@ -375,7 +360,6 @@ macro_rules! benchmarks_iter {
375360 (
376361 { $( $instance: ident ) ? }
377362 { $( $where_clause: tt ) * }
378- { $( $common: tt ) * }
379363 ( $( $names: tt ) * )
380364 ( $( $names_extra: tt ) * )
381365 $name: ident { $( $code: tt ) * } : $dispatch: ident ( $origin: expr $( , $arg: expr ) * )
@@ -384,7 +368,6 @@ macro_rules! benchmarks_iter {
384368 $crate:: benchmarks_iter! {
385369 { $( $instance) ? }
386370 { $( $where_clause ) * }
387- { $( $common ) * }
388371 ( $( $names ) * )
389372 ( $( $names_extra ) * )
390373 $name { $( $code ) * } : $dispatch ( $origin $( , $arg ) * )
@@ -396,7 +379,6 @@ macro_rules! benchmarks_iter {
396379 (
397380 { $( $instance: ident ) ? }
398381 { $( $where_clause: tt ) * }
399- { $( $common: tt ) * }
400382 ( $( $names: tt ) * )
401383 ( $( $names_extra: tt ) * )
402384 $name: ident { $( $code: tt ) * } : $eval: block
@@ -405,7 +387,6 @@ macro_rules! benchmarks_iter {
405387 $crate:: benchmarks_iter!(
406388 { $( $instance) ? }
407389 { $( $where_clause ) * }
408- { $( $common ) * }
409390 ( $( $names ) * )
410391 ( $( $names_extra ) * )
411392 $name { $( $code ) * } : $eval
@@ -423,7 +404,6 @@ macro_rules! benchmark_backend {
423404 { $( $instance: ident ) ? }
424405 $name: ident
425406 { $( $where_clause: tt ) * }
426- { $( $common: tt ) * }
427407 { $( PRE { $( $pre_parsed: tt ) * } ) * }
428408 { $eval: block }
429409 {
@@ -436,7 +416,6 @@ macro_rules! benchmark_backend {
436416 { $( $instance) ? }
437417 $name
438418 { $( $where_clause ) * }
439- { $( $common ) * }
440419 {
441420 $( PRE { $( $pre_parsed ) * } ) *
442421 PRE { $pre_id , $pre_ty , $pre_ex }
@@ -450,7 +429,6 @@ macro_rules! benchmark_backend {
450429 { $( $instance: ident ) ? }
451430 $name: ident
452431 { $( $where_clause: tt ) * }
453- { $( $common: tt ) * }
454432 { $( $parsed: tt ) * }
455433 { $eval: block }
456434 {
@@ -463,7 +441,6 @@ macro_rules! benchmark_backend {
463441 { $( $instance) ? }
464442 $name
465443 { $( $where_clause ) * }
466- { $( $common ) * }
467444 {
468445 $( $parsed ) *
469446 PARAM { $param , $param_from , $param_to , $param_instancer }
@@ -478,7 +455,6 @@ macro_rules! benchmark_backend {
478455 { $( $instance: ident ) ? }
479456 $name: ident
480457 { $( $where_clause: tt ) * }
481- { $( { $common: ident , $common_from: tt , $common_to: expr , $common_instancer: expr } ) * }
482458 { $( $parsed: tt ) * }
483459 { $eval: block }
484460 {
@@ -491,16 +467,8 @@ macro_rules! benchmark_backend {
491467 { $( $instance) ? }
492468 $name
493469 { $( $where_clause ) * }
494- { $( { $common , $common_from , $common_to , $common_instancer } ) * }
495470 { $( $parsed ) * }
496471 { $eval }
497- {
498- let $param
499- in ( { $( let $common = $common_from; ) * $param } )
500- .. ( { $( let $common = $common_to; ) * $param } )
501- => ( { $( let $common = || -> Result <( ) , & ' static str > { $common_instancer ; Ok ( ( ) ) } ; ) * $param( ) ? } ) ;
502- $( $rest ) *
503- }
504472 $postcode
505473 }
506474 } ;
@@ -509,7 +477,6 @@ macro_rules! benchmark_backend {
509477 { $( $instance: ident ) ? }
510478 $name: ident
511479 { $( $where_clause: tt ) * }
512- { $( { $common: ident , $common_from: tt , $common_to: expr , $common_instancer: expr } ) * }
513480 { $( $parsed: tt ) * }
514481 { $eval: block }
515482 {
@@ -522,16 +489,8 @@ macro_rules! benchmark_backend {
522489 { $( $instance) ? }
523490 $name
524491 { $( $where_clause ) * }
525- { $( { $common , $common_from , $common_to , $common_instancer } ) * }
526492 { $( $parsed ) * }
527493 { $eval }
528- {
529- let $param
530- in ( { $( let $common = $common_from; ) * $param } )
531- .. ( { $( let $common = $common_to; ) * $param } )
532- => $param_instancer ;
533- $( $rest ) *
534- }
535494 $postcode
536495 }
537496 } ;
@@ -540,7 +499,6 @@ macro_rules! benchmark_backend {
540499 { $( $instance: ident ) ? }
541500 $name: ident
542501 { $( $where_clause: tt ) * }
543- { $( $common: tt ) * }
544502 { $( $parsed: tt ) * }
545503 { $eval: block }
546504 {
@@ -553,7 +511,6 @@ macro_rules! benchmark_backend {
553511 { $( $instance) ? }
554512 $name
555513 { $( $where_clause ) * }
556- { $( $common ) * }
557514 { $( $parsed ) * }
558515 { $eval }
559516 {
@@ -568,7 +525,6 @@ macro_rules! benchmark_backend {
568525 { $( $instance: ident ) ? }
569526 $name: ident
570527 { $( $where_clause: tt ) * }
571- { $( $common: tt ) * }
572528 { $( $parsed: tt ) * }
573529 { $eval: block }
574530 {
@@ -581,7 +537,6 @@ macro_rules! benchmark_backend {
581537 { $( $instance) ? }
582538 $name
583539 { $( $where_clause ) * }
584- { $( $common ) * }
585540 { $( $parsed ) * }
586541 { $eval }
587542 {
@@ -596,7 +551,6 @@ macro_rules! benchmark_backend {
596551 { $( $instance: ident ) ? }
597552 $name: ident
598553 { $( $where_clause: tt ) * }
599- { $( $common: tt ) * }
600554 { $( $parsed: tt ) * }
601555 { $eval: block }
602556 {
@@ -609,7 +563,6 @@ macro_rules! benchmark_backend {
609563 { $( $instance) ? }
610564 $name
611565 { $( $where_clause ) * }
612- { $( $common ) * }
613566 { $( $parsed ) * }
614567 { $eval }
615568 {
@@ -624,7 +577,6 @@ macro_rules! benchmark_backend {
624577 { $( $instance: ident ) ? }
625578 $name: ident
626579 { $( $where_clause: tt ) * }
627- { $( { $common: ident , $common_from: tt , $common_to: expr , $common_instancer: expr } ) * }
628580 {
629581 $( PRE { $pre_id: tt , $pre_ty: ty , $pre_ex: expr } ) *
630582 $( PARAM { $param: ident , $param_from: expr , $param_to: expr , $param_instancer: expr } ) *
@@ -653,9 +605,6 @@ macro_rules! benchmark_backend {
653605 components: & [ ( $crate:: BenchmarkParameter , u32 ) ] ,
654606 verify: bool
655607 ) -> Result <Box <dyn FnOnce ( ) -> Result <( ) , & ' static str >>, & ' static str > {
656- $(
657- let $common = $common_from;
658- ) *
659608 $(
660609 // Prepare instance
661610 let $param = components. iter( )
0 commit comments