Skip to content

Commit 6f353b5

Browse files
committed
Make the cargo-timing.html filename unique per run.
1 parent 674150e commit 6f353b5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/cargo/core/compiler/timings.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::{CompileMode, Unit};
66
use crate::core::compiler::BuildContext;
77
use crate::core::PackageId;
88
use crate::util::machine_message::{self, Message};
9-
use crate::util::{CargoResult, Config};
9+
use crate::util::{paths, CargoResult, Config};
1010
use std::cmp::max;
1111
use std::collections::HashMap;
1212
use std::fs::File;
@@ -237,7 +237,9 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
237237
/// Save HTML report to disk.
238238
pub fn report_html(&self) -> CargoResult<()> {
239239
let duration = self.start.elapsed().as_secs() as u32 + 1;
240-
let mut f = File::create("cargo-timing.html")?;
240+
let timestamp = self.start_str.replace(&['-', ':'][..], "");
241+
let filename = format!("cargo-timing-{}.html", timestamp);
242+
let mut f = File::create(&filename)?;
241243
let roots: Vec<&str> = self
242244
.root_targets
243245
.iter()
@@ -249,6 +251,18 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
249251
self.fmt_timing_graph(&mut f, graph_width, duration)?;
250252
self.fmt_unit_table(&mut f)?;
251253
f.write_all(HTML_TMPL_FOOT.as_bytes())?;
254+
drop(f);
255+
let msg = format!(
256+
"report saved to {}",
257+
std::env::current_dir()
258+
.unwrap_or_default()
259+
.join(&filename)
260+
.display()
261+
);
262+
paths::link_or_copy(&filename, "cargo-timing.html")?;
263+
self.config
264+
.shell()
265+
.status_with_color("Timing", msg, termcolor::Color::Cyan)?;
252266
Ok(())
253267
}
254268

0 commit comments

Comments
 (0)