@@ -5,20 +5,20 @@ use std::path::Path;
5
5
use super :: path:: { Dirs , RelPath } ;
6
6
use super :: prepare:: GitRepo ;
7
7
use 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 } ;
9
9
10
- pub ( crate ) static SIMPLE_RAYTRACER_REPO : GitRepo = GitRepo :: github (
10
+ static SIMPLE_RAYTRACER_REPO : GitRepo = GitRepo :: github (
11
11
"ebobby" ,
12
12
"simple-raytracer" ,
13
13
"804a7a21b9e673a482797aa289a18ed480e4d813" ,
14
14
"<none>" ,
15
15
) ;
16
16
17
17
// 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 =
19
19
CargoProject :: new ( & SIMPLE_RAYTRACER_REPO . source_dir ( ) , "simple_raytracer_llvm" ) ;
20
20
21
- pub ( crate ) static SIMPLE_RAYTRACER : CargoProject =
21
+ static SIMPLE_RAYTRACER : CargoProject =
22
22
CargoProject :: new ( & SIMPLE_RAYTRACER_REPO . source_dir ( ) , "simple_raytracer" ) ;
23
23
24
24
pub ( crate ) fn benchmark ( dirs : & Dirs , bootstrap_host_compiler : & Compiler ) {
@@ -32,6 +32,15 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
32
32
std:: process:: exit ( 1 ) ;
33
33
}
34
34
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
+
35
44
eprintln ! ( "[LLVM BUILD] simple-raytracer" ) ;
36
45
let build_cmd = SIMPLE_RAYTRACER_LLVM . build ( bootstrap_host_compiler, dirs) ;
37
46
spawn_and_wait ( build_cmd) ;
@@ -45,10 +54,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
45
54
)
46
55
. unwrap ( ) ;
47
56
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 ( ) ;
52
58
53
59
eprintln ! ( "[BENCH COMPILE] ebobby/simple-raytracer" ) ;
54
60
let cargo_clif =
@@ -57,24 +63,24 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
57
63
let target_dir = SIMPLE_RAYTRACER . target_dir ( dirs) ;
58
64
59
65
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}" ,
61
67
manifest_path = manifest_path. display( ) ,
62
68
target_dir = target_dir. display( ) ,
63
69
) ;
64
70
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}" ,
66
72
manifest_path = manifest_path. display( ) ,
67
73
target_dir = target_dir. display( ) ,
68
74
) ;
69
75
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}" ,
71
77
cargo_clif = cargo_clif. display( ) ,
72
78
manifest_path = manifest_path. display( ) ,
73
79
target_dir = target_dir. display( ) ,
74
80
) ;
75
81
76
82
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) ;
78
84
79
85
spawn_and_wait ( bench_compile) ;
80
86
@@ -87,7 +93,7 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
87
93
88
94
let mut bench_run = hyperfine_command (
89
95
0 ,
90
- run_runs ,
96
+ bench_runs ,
91
97
None ,
92
98
Path :: new ( "." ) . join ( get_file_name ( "raytracer_cg_llvm" , "bin" ) ) . to_str ( ) . unwrap ( ) ,
93
99
Path :: new ( "." ) . join ( get_file_name ( "raytracer_cg_clif" , "bin" ) ) . to_str ( ) . unwrap ( ) ,
0 commit comments