@@ -468,28 +468,57 @@ pub fn get_compile_benchmarks(
468
468
let mut excludes = to_hashmap ( exclude) ;
469
469
let mut exclude_suffixes = to_hashmap ( exclude_suffix) ;
470
470
471
+ let mut include_primaries = false ;
472
+ let mut include_secondaries = false ;
473
+ let mut include_stables = false ;
474
+ if let Some ( includes) = includes. as_mut ( ) {
475
+ include_primaries = includes. remove ( & "primary" ) . is_some ( ) ;
476
+ include_secondaries = includes. remove ( & "secondary" ) . is_some ( ) ;
477
+ include_stables = includes. remove ( & "stable" ) . is_some ( ) ;
478
+ }
479
+ let mut exclude_primaries = false ;
480
+ let mut exclude_secondaries = false ;
481
+ let mut exclude_stables = false ;
482
+ if let Some ( excludes) = excludes. as_mut ( ) {
483
+ exclude_primaries = excludes. remove ( & "primary" ) . is_some ( ) ;
484
+ exclude_secondaries = excludes. remove ( & "secondary" ) . is_some ( ) ;
485
+ exclude_stables = excludes. remove ( & "stable" ) . is_some ( ) ;
486
+ }
487
+
471
488
for ( path, name) in paths {
472
489
let mut skip = false ;
490
+ let b = Benchmark :: new ( name, path) ?;
473
491
474
492
let name_matches_prefix = |prefixes : & mut HashMap < & str , usize > | {
475
- substring_matches ( prefixes, |prefix| name. starts_with ( prefix) )
493
+ substring_matches ( prefixes, |prefix| b . name . 0 . starts_with ( prefix) )
476
494
} ;
477
495
496
+ if include. is_none ( ) && exclude. is_none ( ) && b. category ( ) == Category :: Stable {
497
+ // Common case: don't run the stable benchmarks.
498
+ continue ;
499
+ }
500
+
478
501
if let Some ( includes) = includes. as_mut ( ) {
479
- skip |= !name_matches_prefix ( includes) ;
502
+ skip |= !( name_matches_prefix ( includes)
503
+ || ( include_primaries && b. category ( ) == Category :: Primary )
504
+ || ( include_secondaries && b. category ( ) == Category :: Secondary )
505
+ || ( include_stables && b. category ( ) == Category :: Stable ) ) ;
480
506
}
481
507
if let Some ( excludes) = excludes. as_mut ( ) {
482
- skip |= name_matches_prefix ( excludes) ;
508
+ skip |= name_matches_prefix ( excludes)
509
+ || ( exclude_primaries && b. category ( ) == Category :: Primary )
510
+ || ( exclude_secondaries && b. category ( ) == Category :: Secondary )
511
+ || ( exclude_stables && b. category ( ) == Category :: Stable ) ;
483
512
}
484
513
if let Some ( exclude_suffixes) = exclude_suffixes. as_mut ( ) {
485
- skip |= substring_matches ( exclude_suffixes, |suffix| name. ends_with ( suffix) ) ;
514
+ skip |= substring_matches ( exclude_suffixes, |suffix| b . name . 0 . ends_with ( suffix) ) ;
486
515
}
487
516
if skip {
488
517
continue ;
489
518
}
490
519
491
- debug ! ( "benchmark `{}`- registered" , name) ;
492
- benchmarks. push ( Benchmark :: new ( name , path ) ? ) ;
520
+ debug ! ( "benchmark `{}`- registered" , b . name) ;
521
+ benchmarks. push ( b ) ;
493
522
}
494
523
495
524
// All prefixes/suffixes must be used at least once. This is to catch typos.
0 commit comments