@@ -6,7 +6,7 @@ use super::{CompileMode, Unit};
6
6
use crate :: core:: compiler:: BuildContext ;
7
7
use crate :: core:: PackageId ;
8
8
use crate :: util:: machine_message:: { self , Message } ;
9
- use crate :: util:: { CargoResult , Config } ;
9
+ use crate :: util:: { paths , CargoResult , Config } ;
10
10
use std:: cmp:: max;
11
11
use std:: collections:: HashMap ;
12
12
use std:: fs:: File ;
@@ -237,7 +237,9 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
237
237
/// Save HTML report to disk.
238
238
pub fn report_html ( & self ) -> CargoResult < ( ) > {
239
239
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) ?;
241
243
let roots: Vec < & str > = self
242
244
. root_targets
243
245
. iter ( )
@@ -249,6 +251,18 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
249
251
self . fmt_timing_graph ( & mut f, graph_width, duration) ?;
250
252
self . fmt_unit_table ( & mut f) ?;
251
253
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 ) ?;
252
266
Ok ( ( ) )
253
267
}
254
268
0 commit comments