@@ -40,13 +40,14 @@ use collector::compile::benchmark::scenario::Scenario;
40
40
use collector:: compile:: benchmark:: target:: Target ;
41
41
use collector:: compile:: benchmark:: {
42
42
compile_benchmark_dir, get_compile_benchmarks, ArtifactType , Benchmark , BenchmarkName ,
43
+ CompileBenchmarkFilter ,
43
44
} ;
44
45
use collector:: compile:: execute:: bencher:: BenchProcessor ;
45
46
use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
46
47
use collector:: runtime:: {
47
48
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 ,
50
51
} ;
51
52
use collector:: runtime:: { profile_runtime, RuntimeCompilationOpts } ;
52
53
use collector:: toolchain:: {
@@ -105,12 +106,12 @@ struct CompileBenchmarkConfig {
105
106
106
107
struct RuntimeBenchmarkConfig {
107
108
runtime_suite : BenchmarkSuite ,
108
- filter : BenchmarkFilter ,
109
+ filter : RuntimeBenchmarkFilter ,
109
110
iterations : u32 ,
110
111
}
111
112
112
113
impl RuntimeBenchmarkConfig {
113
- fn new ( suite : BenchmarkSuite , filter : BenchmarkFilter , iterations : u32 ) -> Self {
114
+ fn new ( suite : BenchmarkSuite , filter : RuntimeBenchmarkFilter , iterations : u32 ) -> Self {
114
115
Self {
115
116
runtime_suite : suite. filter ( & filter) ,
116
117
filter,
@@ -337,6 +338,16 @@ struct LocalOptions {
337
338
#[ arg( long, value_delimiter = ',' ) ]
338
339
include : Vec < String > ,
339
340
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
+
340
351
/// Include only benchmarks belonging to the given categories.
341
352
#[ arg( long, value_parser = EnumArgParser :: <Category >:: default ( ) , default_value = "Primary,Secondary" ) ]
342
353
category : MultiEnumValue < Category > ,
@@ -688,6 +699,25 @@ enum DownloadSubcommand {
688
699
} ,
689
700
}
690
701
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
+
691
721
fn main_result ( ) -> anyhow:: Result < i32 > {
692
722
env_logger:: init ( ) ;
693
723
@@ -761,7 +791,7 @@ fn main_result() -> anyhow::Result<i32> {
761
791
} ;
762
792
let config = RuntimeBenchmarkConfig :: new (
763
793
runtime_suite,
764
- BenchmarkFilter :: new ( local. exclude , local. include ) ,
794
+ RuntimeBenchmarkFilter :: new ( local. exclude , local. include ) ,
765
795
iterations,
766
796
) ;
767
797
run_benchmarks ( & mut rt, conn, shared, None , Some ( config) ) ?;
@@ -884,12 +914,7 @@ fn main_result() -> anyhow::Result<i32> {
884
914
target_triple,
885
915
) ?;
886
916
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 ( ) ) ?;
893
918
benchmarks. retain ( |b| local. category . 0 . contains ( & b. category ( ) ) ) ;
894
919
895
920
let artifact_id = ArtifactId :: Commit ( Commit {
@@ -1006,9 +1031,11 @@ fn main_result() -> anyhow::Result<i32> {
1006
1031
1007
1032
let mut benchmarks = get_compile_benchmarks (
1008
1033
& 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
+ } ,
1012
1039
) ?;
1013
1040
benchmarks. retain ( |b| b. category ( ) . is_primary_or_secondary ( ) ) ;
1014
1041
@@ -1042,7 +1069,7 @@ fn main_result() -> anyhow::Result<i32> {
1042
1069
1043
1070
let runtime_config = RuntimeBenchmarkConfig {
1044
1071
runtime_suite,
1045
- filter : BenchmarkFilter :: keep_all ( ) ,
1072
+ filter : RuntimeBenchmarkFilter :: keep_all ( ) ,
1046
1073
iterations : DEFAULT_RUNTIME_ITERATIONS ,
1047
1074
} ;
1048
1075
let shared = SharedBenchmarkConfig {
@@ -1102,12 +1129,7 @@ fn main_result() -> anyhow::Result<i32> {
1102
1129
let scenarios = & opts. scenarios . 0 ;
1103
1130
let backends = & opts. codegen_backends . 0 ;
1104
1131
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 ( ) ) ?;
1111
1133
benchmarks. retain ( |b| local. category . 0 . contains ( & b. category ( ) ) ) ;
1112
1134
1113
1135
let mut errors = BenchmarkErrors :: new ( ) ;
@@ -1315,12 +1337,7 @@ fn binary_stats_compile(
1315
1337
Profile :: Opt => CargoProfile :: Release ,
1316
1338
_ => return Err ( anyhow:: anyhow!( "Only Debug and Opt profiles are supported" ) ) ,
1317
1339
} ;
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 ( ) ) ?;
1324
1341
for benchmark in benchmarks {
1325
1342
println ! ( "Stats for benchmark `{}`" , benchmark. name) ;
1326
1343
println ! ( "{}" , "-" . repeat( 20 ) ) ;
@@ -1713,7 +1730,7 @@ fn bench_published_artifact(
1713
1730
} ;
1714
1731
1715
1732
// 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 ) ?;
1717
1734
compile_benchmarks. retain ( |b| b. category ( ) . is_stable ( ) ) ;
1718
1735
1719
1736
let runtime_suite = rt. block_on ( load_runtime_benchmarks (
@@ -1745,7 +1762,7 @@ fn bench_published_artifact(
1745
1762
} ) ,
1746
1763
Some ( RuntimeBenchmarkConfig :: new (
1747
1764
runtime_suite,
1748
- BenchmarkFilter :: keep_all ( ) ,
1765
+ RuntimeBenchmarkFilter :: keep_all ( ) ,
1749
1766
DEFAULT_RUNTIME_ITERATIONS ,
1750
1767
) ) ,
1751
1768
)
0 commit comments