@@ -40,13 +40,14 @@ use collector::compile::benchmark::scenario::Scenario;
4040use collector:: compile:: benchmark:: target:: Target ;
4141use collector:: compile:: benchmark:: {
4242 compile_benchmark_dir, get_compile_benchmarks, ArtifactType , Benchmark , BenchmarkName ,
43+ CompileBenchmarkFilter ,
4344} ;
4445use collector:: compile:: execute:: bencher:: BenchProcessor ;
4546use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
4647use collector:: runtime:: {
4748 bench_runtime, get_runtime_benchmark_groups, prepare_runtime_benchmark_suite,
48- runtime_benchmark_dir, BenchmarkFilter , BenchmarkSuite , BenchmarkSuiteCompilation ,
49- CargoIsolationMode , RuntimeProfiler , DEFAULT_RUNTIME_ITERATIONS ,
49+ runtime_benchmark_dir, BenchmarkSuite , BenchmarkSuiteCompilation , CargoIsolationMode ,
50+ RuntimeBenchmarkFilter , RuntimeProfiler , DEFAULT_RUNTIME_ITERATIONS ,
5051} ;
5152use collector:: runtime:: { profile_runtime, RuntimeCompilationOpts } ;
5253use collector:: toolchain:: {
@@ -105,12 +106,12 @@ struct CompileBenchmarkConfig {
105106
106107struct RuntimeBenchmarkConfig {
107108 runtime_suite : BenchmarkSuite ,
108- filter : BenchmarkFilter ,
109+ filter : RuntimeBenchmarkFilter ,
109110 iterations : u32 ,
110111}
111112
112113impl RuntimeBenchmarkConfig {
113- fn new ( suite : BenchmarkSuite , filter : BenchmarkFilter , iterations : u32 ) -> Self {
114+ fn new ( suite : BenchmarkSuite , filter : RuntimeBenchmarkFilter , iterations : u32 ) -> Self {
114115 Self {
115116 runtime_suite : suite. filter ( & filter) ,
116117 filter,
@@ -337,6 +338,16 @@ struct LocalOptions {
337338 #[ arg( long, value_delimiter = ',' ) ]
338339 include : Vec < String > ,
339340
341+ /// Include only benchmarks in this comma-separated list
342+ #[ arg(
343+ long,
344+ value_delimiter = ',' ,
345+ conflicts_with( "include" ) ,
346+ conflicts_with( "exclude" ) ,
347+ conflicts_with( "exclude_suffix" )
348+ ) ]
349+ exact_match : Vec < String > ,
350+
340351 /// Include only benchmarks belonging to the given categories.
341352 #[ arg( long, value_parser = EnumArgParser :: <Category >:: default ( ) , default_value = "Primary,Secondary" ) ]
342353 category : MultiEnumValue < Category > ,
@@ -688,6 +699,25 @@ enum DownloadSubcommand {
688699 } ,
689700}
690701
702+ impl < ' a > From < & ' a LocalOptions > for CompileBenchmarkFilter < ' a > {
703+ fn from ( value : & ' a LocalOptions ) -> Self {
704+ if !value. exact_match . is_empty ( ) {
705+ Self :: Exact ( & value. exact_match )
706+ } else if !value. include . is_empty ( )
707+ || !value. exclude . is_empty ( )
708+ || !value. exclude_suffix . is_empty ( )
709+ {
710+ Self :: Fuzzy {
711+ include : & value. include ,
712+ exclude : & value. exclude ,
713+ exclude_suffix : & value. exclude_suffix ,
714+ }
715+ } else {
716+ Self :: All
717+ }
718+ }
719+ }
720+
691721fn main_result ( ) -> anyhow:: Result < i32 > {
692722 env_logger:: init ( ) ;
693723
@@ -761,7 +791,7 @@ fn main_result() -> anyhow::Result<i32> {
761791 } ;
762792 let config = RuntimeBenchmarkConfig :: new (
763793 runtime_suite,
764- BenchmarkFilter :: new ( local. exclude , local. include ) ,
794+ RuntimeBenchmarkFilter :: new ( local. exclude , local. include ) ,
765795 iterations,
766796 ) ;
767797 run_benchmarks ( & mut rt, conn, shared, None , Some ( config) ) ?;
@@ -884,12 +914,7 @@ fn main_result() -> anyhow::Result<i32> {
884914 target_triple,
885915 ) ?;
886916
887- let mut benchmarks = get_compile_benchmarks (
888- & compile_benchmark_dir,
889- & local. include ,
890- & local. exclude ,
891- & local. exclude_suffix ,
892- ) ?;
917+ let mut benchmarks = get_compile_benchmarks ( & compile_benchmark_dir, ( & local) . into ( ) ) ?;
893918 benchmarks. retain ( |b| local. category . 0 . contains ( & b. category ( ) ) ) ;
894919
895920 let artifact_id = ArtifactId :: Commit ( Commit {
@@ -1006,9 +1031,11 @@ fn main_result() -> anyhow::Result<i32> {
10061031
10071032 let mut benchmarks = get_compile_benchmarks (
10081033 & compile_benchmark_dir,
1009- & split_args ( include) ,
1010- & split_args ( exclude) ,
1011- & [ ] ,
1034+ CompileBenchmarkFilter :: Fuzzy {
1035+ include : & split_args ( include) ,
1036+ exclude : & split_args ( exclude) ,
1037+ exclude_suffix : & [ ] ,
1038+ } ,
10121039 ) ?;
10131040 benchmarks. retain ( |b| b. category ( ) . is_primary_or_secondary ( ) ) ;
10141041
@@ -1042,7 +1069,7 @@ fn main_result() -> anyhow::Result<i32> {
10421069
10431070 let runtime_config = RuntimeBenchmarkConfig {
10441071 runtime_suite,
1045- filter : BenchmarkFilter :: keep_all ( ) ,
1072+ filter : RuntimeBenchmarkFilter :: keep_all ( ) ,
10461073 iterations : DEFAULT_RUNTIME_ITERATIONS ,
10471074 } ;
10481075 let shared = SharedBenchmarkConfig {
@@ -1102,12 +1129,7 @@ fn main_result() -> anyhow::Result<i32> {
11021129 let scenarios = & opts. scenarios . 0 ;
11031130 let backends = & opts. codegen_backends . 0 ;
11041131
1105- let mut benchmarks = get_compile_benchmarks (
1106- & compile_benchmark_dir,
1107- & local. include ,
1108- & local. exclude ,
1109- & local. exclude_suffix ,
1110- ) ?;
1132+ let mut benchmarks = get_compile_benchmarks ( & compile_benchmark_dir, ( & local) . into ( ) ) ?;
11111133 benchmarks. retain ( |b| local. category . 0 . contains ( & b. category ( ) ) ) ;
11121134
11131135 let mut errors = BenchmarkErrors :: new ( ) ;
@@ -1315,12 +1337,7 @@ fn binary_stats_compile(
13151337 Profile :: Opt => CargoProfile :: Release ,
13161338 _ => return Err ( anyhow:: anyhow!( "Only Debug and Opt profiles are supported" ) ) ,
13171339 } ;
1318- let benchmarks = get_compile_benchmarks (
1319- & compile_benchmark_dir ( ) ,
1320- & local. include ,
1321- & local. exclude ,
1322- & local. exclude_suffix ,
1323- ) ?;
1340+ let benchmarks = get_compile_benchmarks ( & compile_benchmark_dir ( ) , ( & local) . into ( ) ) ?;
13241341 for benchmark in benchmarks {
13251342 println ! ( "Stats for benchmark `{}`" , benchmark. name) ;
13261343 println ! ( "{}" , "-" . repeat( 20 ) ) ;
@@ -1713,7 +1730,7 @@ fn bench_published_artifact(
17131730 } ;
17141731
17151732 // Exclude benchmarks that don't work with a stable compiler.
1716- let mut compile_benchmarks = get_compile_benchmarks ( dirs. compile , & [ ] , & [ ] , & [ ] ) ?;
1733+ let mut compile_benchmarks = get_compile_benchmarks ( dirs. compile , CompileBenchmarkFilter :: All ) ?;
17171734 compile_benchmarks. retain ( |b| b. category ( ) . is_stable ( ) ) ;
17181735
17191736 let runtime_suite = rt. block_on ( load_runtime_benchmarks (
@@ -1745,7 +1762,7 @@ fn bench_published_artifact(
17451762 } ) ,
17461763 Some ( RuntimeBenchmarkConfig :: new (
17471764 runtime_suite,
1748- BenchmarkFilter :: keep_all ( ) ,
1765+ RuntimeBenchmarkFilter :: keep_all ( ) ,
17491766 DEFAULT_RUNTIME_ITERATIONS ,
17501767 ) ) ,
17511768 )
0 commit comments