Skip to content

Commit 84afcee

Browse files
committed
Improve benchmarking step summary format
1 parent 448b7a3 commit 84afcee

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

build_system/bench.rs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
7373
1,
7474
bench_runs,
7575
Some(&clean_cmd),
76-
&[&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+
],
7781
&bench_compile_markdown,
7882
);
7983

8084
spawn_and_wait(bench_compile);
8185

8286
if let Some(gha_step_summary) = gha_step_summary.as_mut() {
83-
gha_step_summary.write_all(b"# Compilation\n\n").unwrap();
87+
gha_step_summary.write_all(b"## Compile ebobby/simple-raytracer\n\n").unwrap();
8488
gha_step_summary.write_all(&std::fs::read(bench_compile_markdown).unwrap()).unwrap();
8589
gha_step_summary.write_all(b"\n").unwrap();
8690
}
@@ -89,31 +93,37 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
8993

9094
let bench_run_markdown = RelPath::DIST.to_path(dirs).join("bench_run.md");
9195

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+
));
92111
let mut bench_run = hyperfine_command(
93112
0,
94113
bench_runs,
95114
None,
96115
&[
97-
Path::new(".")
98-
.join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_llvm", "bin"))
99-
.to_str()
100-
.unwrap(),
101-
Path::new(".")
102-
.join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif", "bin"))
103-
.to_str()
104-
.unwrap(),
105-
Path::new(".")
106-
.join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif_opt", "bin"))
107-
.to_str()
108-
.unwrap(),
116+
("", raytracer_cg_llvm.to_str().unwrap()),
117+
("", raytracer_cg_clif.to_str().unwrap()),
118+
("", raytracer_cg_clif_opt.to_str().unwrap()),
109119
],
110120
&bench_run_markdown,
111121
);
112122
bench_run.current_dir(RelPath::BUILD.to_path(dirs));
113123
spawn_and_wait(bench_run);
114124

115125
if let Some(gha_step_summary) = gha_step_summary.as_mut() {
116-
gha_step_summary.write_all(b"# Execution\n\n").unwrap();
126+
gha_step_summary.write_all(b"## Run ebobby/simple-raytracer\n\n").unwrap();
117127
gha_step_summary.write_all(&std::fs::read(bench_run_markdown).unwrap()).unwrap();
118128
gha_step_summary.write_all(b"\n").unwrap();
119129
}

build_system/utils.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub(crate) fn hyperfine_command(
137137
warmup: u64,
138138
runs: u64,
139139
prepare: Option<&str>,
140-
cmds: &[&str],
140+
cmds: &[(&str, &str)],
141141
markdown_export: &Path,
142142
) -> Command {
143143
let mut bench = Command::new("hyperfine");
@@ -156,7 +156,12 @@ pub(crate) fn hyperfine_command(
156156
bench.arg("--prepare").arg(prepare);
157157
}
158158

159-
bench.args(cmds);
159+
for &(name, cmd) in cmds {
160+
if name != "" {
161+
bench.arg("-n").arg(name);
162+
}
163+
bench.arg(cmd);
164+
}
160165

161166
bench
162167
}

0 commit comments

Comments
 (0)