@@ -31,8 +31,9 @@ use tokio::runtime::Runtime;
31
31
use collector:: compile:: execute:: bencher:: BenchProcessor ;
32
32
use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
33
33
use collector:: runtime:: {
34
- bench_runtime, runtime_benchmark_dir, BenchmarkFilter , BenchmarkSuite ,
35
- BenchmarkSuiteCompilation , CargoIsolationMode , DEFAULT_RUNTIME_ITERATIONS ,
34
+ bench_runtime, prepare_runtime_benchmark_suite, profile_runtime, runtime_benchmark_dir,
35
+ BenchmarkFilter , BenchmarkSuite , BenchmarkSuiteCompilation , CargoIsolationMode ,
36
+ DEFAULT_RUNTIME_ITERATIONS ,
36
37
} ;
37
38
use collector:: toolchain:: {
38
39
create_toolchain_from_published_version, get_local_toolchain, Sysroot , Toolchain ,
@@ -245,7 +246,7 @@ fn cg_annotate(cgout: &Path, path: &Path) -> anyhow::Result<()> {
245
246
}
246
247
247
248
#[ allow( clippy:: too_many_arguments) ]
248
- fn profile (
249
+ fn profile_compile (
249
250
toolchain : & Toolchain ,
250
251
profiler : Profiler ,
251
252
out_dir : & Path ,
@@ -492,6 +493,16 @@ enum Commands {
492
493
#[ arg( long = "no-isolate" ) ]
493
494
no_isolate : bool ,
494
495
} ,
496
+
497
+ /// Profiles a runtime benchmark.
498
+ ProfileRuntime {
499
+ #[ command( flatten) ]
500
+ local : LocalOptions ,
501
+
502
+ /// Name of the benchmark that should be profiled
503
+ benchmark : String ,
504
+ } ,
505
+
495
506
/// Benchmarks a local rustc
496
507
BenchLocal {
497
508
#[ command( flatten) ]
@@ -640,15 +651,7 @@ fn main_result() -> anyhow::Result<i32> {
640
651
no_isolate,
641
652
} => {
642
653
log_db ( & db) ;
643
- let toolchain = get_local_toolchain (
644
- & [ Profile :: Opt ] ,
645
- & local. rustc ,
646
- None ,
647
- local. cargo . as_deref ( ) ,
648
- local. id . as_deref ( ) ,
649
- "" ,
650
- target_triple,
651
- ) ?;
654
+ let toolchain = get_local_toolchain_for_runtime_benchmarks ( & local, & target_triple) ?;
652
655
let pool = Pool :: open ( & db. db ) ;
653
656
654
657
let isolation_mode = if no_isolate {
@@ -679,6 +682,17 @@ fn main_result() -> anyhow::Result<i32> {
679
682
run_benchmarks ( & mut rt, conn, shared, None , Some ( config) ) ?;
680
683
Ok ( 0 )
681
684
}
685
+ Commands :: ProfileRuntime { local, benchmark } => {
686
+ let toolchain = get_local_toolchain_for_runtime_benchmarks ( & local, & target_triple) ?;
687
+ let suite = prepare_runtime_benchmark_suite (
688
+ & toolchain,
689
+ & runtime_benchmark_dir,
690
+ CargoIsolationMode :: Cached ,
691
+ ) ?
692
+ . suite ;
693
+ profile_runtime ( suite, & benchmark) ?;
694
+ Ok ( 0 )
695
+ }
682
696
Commands :: BenchLocal {
683
697
local,
684
698
opts,
@@ -894,7 +908,7 @@ fn main_result() -> anyhow::Result<i32> {
894
908
target_triple. clone ( ) ,
895
909
) ?;
896
910
let id = toolchain. id . clone ( ) ;
897
- profile (
911
+ profile_compile (
898
912
& toolchain,
899
913
profiler,
900
914
& out_dir,
@@ -995,6 +1009,21 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
995
1009
}
996
1010
}
997
1011
1012
+ fn get_local_toolchain_for_runtime_benchmarks (
1013
+ local : & LocalOptions ,
1014
+ target_triple : & str ,
1015
+ ) -> anyhow:: Result < Toolchain > {
1016
+ get_local_toolchain (
1017
+ & [ Profile :: Opt ] ,
1018
+ & local. rustc ,
1019
+ None ,
1020
+ local. cargo . as_deref ( ) ,
1021
+ local. id . as_deref ( ) ,
1022
+ "" ,
1023
+ target_triple. to_string ( ) ,
1024
+ )
1025
+ }
1026
+
998
1027
async fn load_runtime_benchmarks (
999
1028
conn : & mut dyn Connection ,
1000
1029
benchmark_dir : & Path ,
0 commit comments