|
1 | 1 | use super::build_sysroot;
|
2 | 2 | use super::config;
|
3 | 3 | use super::rustc_info::get_wrapper_file_name;
|
4 |
| -use super::utils::{cargo_command, spawn_and_wait, spawn_and_wait_with_input}; |
| 4 | +use super::utils::{cargo_command, hyperfine_command, spawn_and_wait, spawn_and_wait_with_input}; |
5 | 5 | use build_system::SysrootKind;
|
6 | 6 | use std::env;
|
7 | 7 | use std::ffi::OsStr;
|
@@ -231,40 +231,37 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
231 | 231 | }),
|
232 | 232 | TestCase::new("bench.simple-raytracer", &|runner| {
|
233 | 233 | runner.in_dir(["simple-raytracer"], |runner| {
|
234 |
| - let run_runs = env::var("RUN_RUNS").unwrap_or("10".to_string()); |
| 234 | + let run_runs = env::var("RUN_RUNS").unwrap_or("10".to_string()).parse().unwrap(); |
235 | 235 |
|
236 | 236 | if runner.host_triple == runner.target_triple {
|
237 | 237 | eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
|
238 |
| - let mut bench_compile = Command::new("hyperfine"); |
239 |
| - bench_compile.arg("--runs"); |
240 |
| - bench_compile.arg(&run_runs); |
241 |
| - bench_compile.arg("--warmup"); |
242 |
| - bench_compile.arg("1"); |
243 |
| - bench_compile.arg("--prepare"); |
244 |
| - bench_compile.arg(format!("{:?}", runner.cargo_command("clean", []))); |
| 238 | + let prepare = runner.cargo_command("clean", []); |
245 | 239 |
|
246 |
| - bench_compile.arg("cargo build"); |
| 240 | + let llvm_build_cmd = cargo_command("cargo", "build", None, Path::new(".")); |
247 | 241 |
|
248 | 242 | let cargo_clif = runner
|
249 | 243 | .root_dir
|
250 | 244 | .clone()
|
251 | 245 | .join("build")
|
252 | 246 | .join(get_wrapper_file_name("cargo-clif", "bin"));
|
253 |
| - let mut clif_build_cmd = cargo_command(cargo_clif, "build", None, Path::new(".")); |
254 |
| - clif_build_cmd.env("RUSTFLAGS", &runner.rust_flags); |
255 |
| - bench_compile.arg(format!("{:?}", clif_build_cmd)); |
| 247 | + let clif_build_cmd = cargo_command(cargo_clif, "build", None, Path::new(".")); |
| 248 | + |
| 249 | + let bench_compile = |
| 250 | + hyperfine_command(1, run_runs, Some(prepare), llvm_build_cmd, clif_build_cmd); |
256 | 251 |
|
257 | 252 | spawn_and_wait(bench_compile);
|
258 | 253 |
|
259 | 254 | eprintln!("[BENCH RUN] ebobby/simple-raytracer");
|
260 | 255 | fs::copy(PathBuf::from("./target/debug/main"), PathBuf::from("raytracer_cg_clif"))
|
261 | 256 | .unwrap();
|
262 | 257 |
|
263 |
| - let mut bench_run = Command::new("hyperfine"); |
264 |
| - bench_run.arg("--runs"); |
265 |
| - bench_run.arg(&run_runs); |
266 |
| - bench_run.arg(PathBuf::from("./raytracer_cg_llvm")); |
267 |
| - bench_run.arg(PathBuf::from("./raytracer_cg_clif")); |
| 258 | + let bench_run = hyperfine_command( |
| 259 | + 0, |
| 260 | + run_runs, |
| 261 | + None, |
| 262 | + Command::new("./raytracer_cg_llvm"), |
| 263 | + Command::new("./raytracer_cg_clif"), |
| 264 | + ); |
268 | 265 | spawn_and_wait(bench_run);
|
269 | 266 | } else {
|
270 | 267 | runner.run_cargo("clean", []);
|
|
0 commit comments