@@ -5,20 +5,20 @@ use std::path::Path;
55use super :: path:: { Dirs , RelPath } ;
66use super :: prepare:: GitRepo ;
77use super :: rustc_info:: get_file_name;
8- use super :: utils:: { hyperfine_command, is_ci , spawn_and_wait, CargoProject , Compiler } ;
8+ use super :: utils:: { hyperfine_command, spawn_and_wait, CargoProject , Compiler } ;
99
10- pub ( crate ) static SIMPLE_RAYTRACER_REPO : GitRepo = GitRepo :: github (
10+ static SIMPLE_RAYTRACER_REPO : GitRepo = GitRepo :: github (
1111 "ebobby" ,
1212 "simple-raytracer" ,
1313 "804a7a21b9e673a482797aa289a18ed480e4d813" ,
1414 "<none>" ,
1515) ;
1616
1717// Use a separate target dir for the initial LLVM build to reduce unnecessary recompiles
18- pub ( crate ) static SIMPLE_RAYTRACER_LLVM : CargoProject =
18+ static SIMPLE_RAYTRACER_LLVM : CargoProject =
1919 CargoProject :: new ( & SIMPLE_RAYTRACER_REPO . source_dir ( ) , "simple_raytracer_llvm" ) ;
2020
21- pub ( crate ) static SIMPLE_RAYTRACER : CargoProject =
21+ static SIMPLE_RAYTRACER : CargoProject =
2222 CargoProject :: new ( & SIMPLE_RAYTRACER_REPO . source_dir ( ) , "simple_raytracer" ) ;
2323
2424pub ( crate ) fn benchmark ( dirs : & Dirs , bootstrap_host_compiler : & Compiler ) {
@@ -32,6 +32,15 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
3232 std:: process:: exit ( 1 ) ;
3333 }
3434
35+ if !SIMPLE_RAYTRACER_REPO . source_dir ( ) . to_path ( dirs) . exists ( ) {
36+ SIMPLE_RAYTRACER_REPO . fetch ( dirs) ;
37+ spawn_and_wait ( SIMPLE_RAYTRACER . fetch (
38+ & bootstrap_host_compiler. cargo ,
39+ & bootstrap_host_compiler. rustc ,
40+ dirs,
41+ ) ) ;
42+ }
43+
3544 eprintln ! ( "[LLVM BUILD] simple-raytracer" ) ;
3645 let build_cmd = SIMPLE_RAYTRACER_LLVM . build ( bootstrap_host_compiler, dirs) ;
3746 spawn_and_wait ( build_cmd) ;
@@ -45,10 +54,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
4554 )
4655 . unwrap ( ) ;
4756
48- let run_runs = env:: var ( "RUN_RUNS" )
49- . unwrap_or ( if is_ci ( ) { "2" } else { "10" } . to_string ( ) )
50- . parse ( )
51- . unwrap ( ) ;
57+ let bench_runs = env:: var ( "BENCH_RUNS" ) . unwrap_or_else ( |_| "10" . to_string ( ) ) . parse ( ) . unwrap ( ) ;
5258
5359 eprintln ! ( "[BENCH COMPILE] ebobby/simple-raytracer" ) ;
5460 let cargo_clif =
@@ -57,24 +63,24 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
5763 let target_dir = SIMPLE_RAYTRACER . target_dir ( dirs) ;
5864
5965 let clean_cmd = format ! (
60- "cargo clean --manifest-path {manifest_path} --target-dir {target_dir}" ,
66+ "RUSTC=rustc cargo clean --manifest-path {manifest_path} --target-dir {target_dir}" ,
6167 manifest_path = manifest_path. display( ) ,
6268 target_dir = target_dir. display( ) ,
6369 ) ;
6470 let llvm_build_cmd = format ! (
65- "cargo build --manifest-path {manifest_path} --target-dir {target_dir}" ,
71+ "RUSTC=rustc cargo build --manifest-path {manifest_path} --target-dir {target_dir}" ,
6672 manifest_path = manifest_path. display( ) ,
6773 target_dir = target_dir. display( ) ,
6874 ) ;
6975 let clif_build_cmd = format ! (
70- "{cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir}" ,
76+ "RUSTC=rustc {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir}" ,
7177 cargo_clif = cargo_clif. display( ) ,
7278 manifest_path = manifest_path. display( ) ,
7379 target_dir = target_dir. display( ) ,
7480 ) ;
7581
7682 let bench_compile =
77- hyperfine_command ( 1 , run_runs , Some ( & clean_cmd) , & llvm_build_cmd, & clif_build_cmd) ;
83+ hyperfine_command ( 1 , bench_runs , Some ( & clean_cmd) , & llvm_build_cmd, & clif_build_cmd) ;
7884
7985 spawn_and_wait ( bench_compile) ;
8086
@@ -87,7 +93,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
8793
8894 let mut bench_run = hyperfine_command (
8995 0 ,
90- run_runs ,
96+ bench_runs ,
9197 None ,
9298 Path :: new ( "." ) . join ( get_file_name ( "raytracer_cg_llvm" , "bin" ) ) . to_str ( ) . unwrap ( ) ,
9399 Path :: new ( "." ) . join ( get_file_name ( "raytracer_cg_clif" , "bin" ) ) . to_str ( ) . unwrap ( ) ,
0 commit comments