|
1 | 1 | use std::env;
|
| 2 | +use std::io::Write; |
2 | 3 | use std::path::Path;
|
3 | 4 |
|
4 | 5 | use super::path::{Dirs, RelPath};
|
@@ -30,6 +31,12 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
|
30 | 31 |
|
31 | 32 | let bench_runs = env::var("BENCH_RUNS").unwrap_or_else(|_| "10".to_string()).parse().unwrap();
|
32 | 33 |
|
| 34 | + let mut gha_step_summary = if let Ok(file) = std::env::var("GITHUB_STEP_SUMMARY") { |
| 35 | + Some(std::fs::OpenOptions::new().append(true).open(file).unwrap()) |
| 36 | + } else { |
| 37 | + None |
| 38 | + }; |
| 39 | + |
33 | 40 | eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
|
34 | 41 | let cargo_clif = RelPath::DIST
|
35 | 42 | .to_path(dirs)
|
@@ -60,36 +67,64 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
|
60 | 67 | target_dir = target_dir.display(),
|
61 | 68 | );
|
62 | 69 |
|
| 70 | + let bench_compile_markdown = RelPath::DIST.to_path(dirs).join("bench_compile.md"); |
| 71 | + |
63 | 72 | let bench_compile = hyperfine_command(
|
64 | 73 | 1,
|
65 | 74 | bench_runs,
|
66 | 75 | Some(&clean_cmd),
|
67 |
| - &[&llvm_build_cmd, &clif_build_cmd, &clif_build_opt_cmd], |
| 76 | + &[ |
| 77 | + ("cargo build", &llvm_build_cmd), |
| 78 | + ("cargo-clif build", &clif_build_cmd), |
| 79 | + ("cargo-clif build --release", &clif_build_opt_cmd), |
| 80 | + ], |
| 81 | + &bench_compile_markdown, |
68 | 82 | );
|
69 | 83 |
|
70 | 84 | spawn_and_wait(bench_compile);
|
71 | 85 |
|
| 86 | + if let Some(gha_step_summary) = gha_step_summary.as_mut() { |
| 87 | + gha_step_summary.write_all(b"## Compile ebobby/simple-raytracer\n\n").unwrap(); |
| 88 | + gha_step_summary.write_all(&std::fs::read(bench_compile_markdown).unwrap()).unwrap(); |
| 89 | + gha_step_summary.write_all(b"\n").unwrap(); |
| 90 | + } |
| 91 | + |
72 | 92 | eprintln!("[BENCH RUN] ebobby/simple-raytracer");
|
73 | 93 |
|
| 94 | + let bench_run_markdown = RelPath::DIST.to_path(dirs).join("bench_run.md"); |
| 95 | + |
| 96 | + let raytracer_cg_llvm = Path::new(".").join(get_file_name( |
| 97 | + &bootstrap_host_compiler.rustc, |
| 98 | + "raytracer_cg_llvm", |
| 99 | + "bin", |
| 100 | + )); |
| 101 | + let raytracer_cg_clif = Path::new(".").join(get_file_name( |
| 102 | + &bootstrap_host_compiler.rustc, |
| 103 | + "raytracer_cg_clif", |
| 104 | + "bin", |
| 105 | + )); |
| 106 | + let raytracer_cg_clif_opt = Path::new(".").join(get_file_name( |
| 107 | + &bootstrap_host_compiler.rustc, |
| 108 | + "raytracer_cg_clif_opt", |
| 109 | + "bin", |
| 110 | + )); |
74 | 111 | let mut bench_run = hyperfine_command(
|
75 | 112 | 0,
|
76 | 113 | bench_runs,
|
77 | 114 | None,
|
78 | 115 | &[
|
79 |
| - Path::new(".") |
80 |
| - .join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_llvm", "bin")) |
81 |
| - .to_str() |
82 |
| - .unwrap(), |
83 |
| - Path::new(".") |
84 |
| - .join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif", "bin")) |
85 |
| - .to_str() |
86 |
| - .unwrap(), |
87 |
| - Path::new(".") |
88 |
| - .join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif_opt", "bin")) |
89 |
| - .to_str() |
90 |
| - .unwrap(), |
| 116 | + ("", raytracer_cg_llvm.to_str().unwrap()), |
| 117 | + ("", raytracer_cg_clif.to_str().unwrap()), |
| 118 | + ("", raytracer_cg_clif_opt.to_str().unwrap()), |
91 | 119 | ],
|
| 120 | + &bench_run_markdown, |
92 | 121 | );
|
93 | 122 | bench_run.current_dir(RelPath::BUILD.to_path(dirs));
|
94 | 123 | spawn_and_wait(bench_run);
|
| 124 | + |
| 125 | + if let Some(gha_step_summary) = gha_step_summary.as_mut() { |
| 126 | + gha_step_summary.write_all(b"## Run ebobby/simple-raytracer\n\n").unwrap(); |
| 127 | + gha_step_summary.write_all(&std::fs::read(bench_run_markdown).unwrap()).unwrap(); |
| 128 | + gha_step_summary.write_all(b"\n").unwrap(); |
| 129 | + } |
95 | 130 | }
|
0 commit comments