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,17 +67,28 @@ 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
76
& [ & llvm_build_cmd, & clif_build_cmd, & clif_build_opt_cmd] ,
77
+ & bench_compile_markdown,
68
78
) ;
69
79
70
80
spawn_and_wait ( bench_compile) ;
71
81
82
+ if let Some ( gha_step_summary) = gha_step_summary. as_mut ( ) {
83
+ gha_step_summary. write_all ( b"# Compilation\n \n " ) . unwrap ( ) ;
84
+ gha_step_summary. write_all ( & std:: fs:: read ( bench_compile_markdown) . unwrap ( ) ) . unwrap ( ) ;
85
+ gha_step_summary. write_all ( b"\n " ) . unwrap ( ) ;
86
+ }
87
+
72
88
eprintln ! ( "[BENCH RUN] ebobby/simple-raytracer" ) ;
73
89
90
+ let bench_run_markdown = RelPath :: DIST . to_path ( dirs) . join ( "bench_run.md" ) ;
91
+
74
92
let mut bench_run = hyperfine_command (
75
93
0 ,
76
94
bench_runs,
@@ -89,7 +107,14 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
89
107
. to_str ( )
90
108
. unwrap ( ) ,
91
109
] ,
110
+ & bench_run_markdown,
92
111
) ;
93
112
bench_run. current_dir ( RelPath :: BUILD . to_path ( dirs) ) ;
94
113
spawn_and_wait ( bench_run) ;
114
+
115
+ if let Some ( gha_step_summary) = gha_step_summary. as_mut ( ) {
116
+ gha_step_summary. write_all ( b"# Execution\n \n " ) . unwrap ( ) ;
117
+ gha_step_summary. write_all ( & std:: fs:: read ( bench_run_markdown) . unwrap ( ) ) . unwrap ( ) ;
118
+ gha_step_summary. write_all ( b"\n " ) . unwrap ( ) ;
119
+ }
95
120
}
0 commit comments