@@ -375,32 +375,52 @@ fn get_benchmarks(
375375 }
376376 paths. push ( ( PathBuf :: from ( "rustc" ) , String :: from ( "rustc" ) ) ) ;
377377
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 ( ) ) {
384385 debug ! (
385- "benchmark {} - doesn't match --include argument, skipping" ,
386+ "benchmark {} - not named by --include argument, skipping" ,
386387 name
387388 ) ;
388- continue ' outer ;
389+ skip = true ;
389390 }
390391 }
391392
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 ;
398397 }
399398 }
399+ if skip {
400+ continue ;
401+ }
400402
401403 debug ! ( "benchmark `{}`- registered" , name) ;
402404 benchmarks. push ( Benchmark :: new ( name, path) ?) ;
403405 }
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+
404424 benchmarks. sort_by_key ( |benchmark| benchmark. name . clone ( ) ) ;
405425
406426 if benchmarks. is_empty ( ) {
@@ -717,10 +737,10 @@ fn main_result() -> anyhow::Result<i32> {
717737 ( @arg CARGO : --cargo +takes_value "The path to the local Cargo to use" )
718738 ( @arg DB : --db +takes_value "Database output file" )
719739 ( @arg EXCLUDE : --exclude +takes_value
720- "Exclude all benchmarks matching anything in\n \
740+ "Exclude all benchmarks that are listed in\n \
721741 this comma-separated list of patterns")
722742 ( @arg INCLUDE : --include +takes_value
723- "Include only benchmarks matching something in\n \
743+ "Include only benchmarks that are listed in\n \
724744 this comma-separated list of patterns")
725745 ( @arg RUNS : --runs +takes_value
726746 "One or more (comma-separated) of: 'Full',\n \
@@ -769,10 +789,10 @@ fn main_result() -> anyhow::Result<i32> {
769789 'Debug', 'Doc', 'Opt', 'All'")
770790 ( @arg CARGO : --cargo +takes_value "The path to the local Cargo to use" )
771791 ( @arg EXCLUDE : --exclude +takes_value
772- "Exclude all benchmarks matching anything in\n \
792+ "Exclude all benchmarks that are listed in\n \
773793 this comma-separated list of patterns")
774794 ( @arg INCLUDE : --include +takes_value
775- "Include only benchmarks matching something in\n \
795+ "Include only benchmarks that are listed in\n \
776796 this comma-separated list of patterns")
777797 ( @arg OUT_DIR : --( "out-dir" ) +takes_value "Output directory" )
778798 ( @arg RUNS : --runs +takes_value
@@ -798,10 +818,10 @@ fn main_result() -> anyhow::Result<i32> {
798818 'Debug', 'Doc', 'Opt', 'All'")
799819 ( @arg CARGO : --cargo +takes_value "The path to the local Cargo to use" )
800820 ( @arg EXCLUDE : --exclude +takes_value
801- "Exclude all benchmarks matching anything in\n \
821+ "Exclude all benchmarks that are listed in\n \
802822 this comma-separated list of patterns")
803823 ( @arg INCLUDE : --include +takes_value
804- "Include only benchmarks matching something in\n \
824+ "Include only benchmarks that are listed in\n \
805825 this comma-separated list of patterns")
806826 ( @arg OUT_DIR : --( "out-dir" ) +takes_value "Output directory" )
807827 ( @arg RUNS : --runs +takes_value
0 commit comments