Skip to content

Commit eac1ed5

Browse files
committed
enable report summary when BOOTSTRAP_PROFILE is set
1 parent 75b454b commit eac1ed5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/bootstrap/src/bin/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use std::fs::{self, OpenOptions};
99
use std::io::{self, BufRead, BufReader, IsTerminal, Write};
1010
use std::str::FromStr;
11+
use std::time::Instant;
1112
use std::{env, process};
1213

1314
use bootstrap::{
@@ -17,11 +18,17 @@ use bootstrap::{
1718
#[cfg(feature = "tracing")]
1819
use tracing::instrument;
1920

21+
fn is_bootstrap_profiling_enabled() -> bool {
22+
env::var("BOOTSTRAP_PROFILE").is_ok_and(|v| v == "1")
23+
}
24+
2025
#[cfg_attr(feature = "tracing", instrument(level = "trace", name = "main"))]
2126
fn main() {
2227
#[cfg(feature = "tracing")]
2328
let _guard = setup_tracing();
2429

30+
let start_time = Instant::now();
31+
2532
let args = env::args().skip(1).collect::<Vec<_>>();
2633

2734
if Flags::try_parse_verbose_help(&args) {
@@ -96,7 +103,8 @@ fn main() {
96103
let out_dir = config.out.clone();
97104

98105
debug!("creating new build based on config");
99-
Build::new(config).build();
106+
let mut build = Build::new(config);
107+
build.build();
100108

101109
if suggest_setup {
102110
println!("WARNING: you have not made a `bootstrap.toml`");
@@ -147,6 +155,10 @@ fn main() {
147155
t!(file.write_all(lines.join("\n").as_bytes()));
148156
}
149157
}
158+
159+
if is_bootstrap_profiling_enabled() {
160+
build.report_summary(start_time);
161+
}
150162
}
151163

152164
fn check_version(config: &Config) -> Option<String> {
@@ -226,7 +238,7 @@ fn setup_tracing() -> impl Drop {
226238
let mut chrome_layer = tracing_chrome::ChromeLayerBuilder::new().include_args(true);
227239

228240
// Writes the Chrome profile to trace-<unix-timestamp>.json if enabled
229-
if !env::var("BOOTSTRAP_PROFILE").is_ok_and(|v| v == "1") {
241+
if !is_bootstrap_profiling_enabled() {
230242
chrome_layer = chrome_layer.writer(io::sink());
231243
}
232244

0 commit comments

Comments
 (0)