@@ -31,8 +31,9 @@ use tokio::runtime::Runtime;
3131use collector:: compile:: execute:: bencher:: BenchProcessor ;
3232use collector:: compile:: execute:: profiler:: { ProfileProcessor , Profiler } ;
3333use 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 ,
3637} ;
3738use collector:: toolchain:: {
3839 create_toolchain_from_published_version, get_local_toolchain, Sysroot , Toolchain ,
@@ -245,7 +246,7 @@ fn cg_annotate(cgout: &Path, path: &Path) -> anyhow::Result<()> {
245246}
246247
247248#[ allow( clippy:: too_many_arguments) ]
248- fn profile (
249+ fn profile_compile (
249250 toolchain : & Toolchain ,
250251 profiler : Profiler ,
251252 out_dir : & Path ,
@@ -492,6 +493,16 @@ enum Commands {
492493 #[ arg( long = "no-isolate" ) ]
493494 no_isolate : bool ,
494495 } ,
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+
495506 /// Benchmarks a local rustc
496507 BenchLocal {
497508 #[ command( flatten) ]
@@ -640,15 +651,7 @@ fn main_result() -> anyhow::Result<i32> {
640651 no_isolate,
641652 } => {
642653 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) ?;
652655 let pool = Pool :: open ( & db. db ) ;
653656
654657 let isolation_mode = if no_isolate {
@@ -679,6 +682,17 @@ fn main_result() -> anyhow::Result<i32> {
679682 run_benchmarks ( & mut rt, conn, shared, None , Some ( config) ) ?;
680683 Ok ( 0 )
681684 }
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+ }
682696 Commands :: BenchLocal {
683697 local,
684698 opts,
@@ -894,7 +908,7 @@ fn main_result() -> anyhow::Result<i32> {
894908 target_triple. clone ( ) ,
895909 ) ?;
896910 let id = toolchain. id . clone ( ) ;
897- profile (
911+ profile_compile (
898912 & toolchain,
899913 profiler,
900914 & out_dir,
@@ -995,6 +1009,21 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
9951009 }
9961010}
9971011
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+
9981027async fn load_runtime_benchmarks (
9991028 conn : & mut dyn Connection ,
10001029 benchmark_dir : & Path ,
0 commit comments