@@ -375,32 +375,52 @@ fn get_benchmarks(
375
375
}
376
376
paths. push ( ( PathBuf :: from ( "rustc" ) , String :: from ( "rustc" ) ) ) ;
377
377
378
- ' outer: for ( path, name) in paths {
379
- if let Some ( include) = include {
380
- if !include
381
- . split ( ',' )
382
- . any ( |to_include| name. contains ( to_include) )
383
- {
378
+ let mut includes = include. map ( |list| list. split ( ',' ) . collect :: < HashSet < _ > > ( ) ) ;
379
+ let mut excludes = exclude. map ( |list| list. split ( ',' ) . collect :: < HashSet < _ > > ( ) ) ;
380
+
381
+ for ( path, name) in paths {
382
+ let mut skip = false ;
383
+ if let Some ( includes) = includes. as_mut ( ) {
384
+ if !includes. remove ( name. as_str ( ) ) {
384
385
debug ! (
385
- "benchmark {} - doesn't match --include argument, skipping" ,
386
+ "benchmark {} - not named by --include argument, skipping" ,
386
387
name
387
388
) ;
388
- continue ' outer ;
389
+ skip = true ;
389
390
}
390
391
}
391
392
392
- if let Some ( exclude) = exclude {
393
- for exc in exclude. split ( ',' ) {
394
- if name. contains ( exc) {
395
- debug ! ( "benchmark {} - matches --exclude argument, skipping" , name) ;
396
- continue ' outer;
397
- }
393
+ if let Some ( excludes) = excludes. as_mut ( ) {
394
+ if excludes. remove ( name. as_str ( ) ) {
395
+ debug ! ( "benchmark {} - named by --exclude argument, skipping" , name) ;
396
+ skip = true ;
398
397
}
399
398
}
399
+ if skip {
400
+ continue ;
401
+ }
400
402
401
403
debug ! ( "benchmark `{}`- registered" , name) ;
402
404
benchmarks. push ( Benchmark :: new ( name, path) ?) ;
403
405
}
406
+
407
+ if let Some ( includes) = includes {
408
+ if !includes. is_empty ( ) {
409
+ bail ! (
410
+ "Warning: one or more invalid --include entries: {:?}" ,
411
+ includes
412
+ ) ;
413
+ }
414
+ }
415
+ if let Some ( excludes) = excludes {
416
+ if !excludes. is_empty ( ) {
417
+ bail ! (
418
+ "Warning: one or more invalid --exclude entries: {:?}" ,
419
+ excludes
420
+ ) ;
421
+ }
422
+ }
423
+
404
424
benchmarks. sort_by_key ( |benchmark| benchmark. name . clone ( ) ) ;
405
425
406
426
if benchmarks. is_empty ( ) {
@@ -717,10 +737,10 @@ fn main_result() -> anyhow::Result<i32> {
717
737
( @arg CARGO : --cargo +takes_value "The path to the local Cargo to use" )
718
738
( @arg DB : --db +takes_value "Database output file" )
719
739
( @arg EXCLUDE : --exclude +takes_value
720
- "Exclude all benchmarks matching anything in\n \
740
+ "Exclude all benchmarks that are listed in\n \
721
741
this comma-separated list of patterns")
722
742
( @arg INCLUDE : --include +takes_value
723
- "Include only benchmarks matching something in\n \
743
+ "Include only benchmarks that are listed in\n \
724
744
this comma-separated list of patterns")
725
745
( @arg RUNS : --runs +takes_value
726
746
"One or more (comma-separated) of: 'Full',\n \
@@ -769,10 +789,10 @@ fn main_result() -> anyhow::Result<i32> {
769
789
'Debug', 'Doc', 'Opt', 'All'")
770
790
( @arg CARGO : --cargo +takes_value "The path to the local Cargo to use" )
771
791
( @arg EXCLUDE : --exclude +takes_value
772
- "Exclude all benchmarks matching anything in\n \
792
+ "Exclude all benchmarks that are listed in\n \
773
793
this comma-separated list of patterns")
774
794
( @arg INCLUDE : --include +takes_value
775
- "Include only benchmarks matching something in\n \
795
+ "Include only benchmarks that are listed in\n \
776
796
this comma-separated list of patterns")
777
797
( @arg OUT_DIR : --( "out-dir" ) +takes_value "Output directory" )
778
798
( @arg RUNS : --runs +takes_value
@@ -798,10 +818,10 @@ fn main_result() -> anyhow::Result<i32> {
798
818
'Debug', 'Doc', 'Opt', 'All'")
799
819
( @arg CARGO : --cargo +takes_value "The path to the local Cargo to use" )
800
820
( @arg EXCLUDE : --exclude +takes_value
801
- "Exclude all benchmarks matching anything in\n \
821
+ "Exclude all benchmarks that are listed in\n \
802
822
this comma-separated list of patterns")
803
823
( @arg INCLUDE : --include +takes_value
804
- "Include only benchmarks matching something in\n \
824
+ "Include only benchmarks that are listed in\n \
805
825
this comma-separated list of patterns")
806
826
( @arg OUT_DIR : --( "out-dir" ) +takes_value "Output directory" )
807
827
( @arg RUNS : --runs +takes_value
0 commit comments