@@ -64,8 +64,9 @@ pub struct Timings<'gctx> {
6464 cpu_usage : Vec < ( f64 , f64 ) > ,
6565}
6666
67- /// Section of compilation.
68- struct TimingSection {
67+ /// Section of compilation (e.g. frontend, backend, linking).
68+ #[ derive( Copy , Clone , serde:: Serialize ) ]
69+ pub struct CompilationSection {
6970 /// Start of the section, as an offset in seconds from `UnitTime::start`.
7071 start : f64 ,
7172 /// End of the section, as an offset in seconds from `UnitTime::start`.
@@ -89,7 +90,7 @@ struct UnitTime {
8990 /// Same as `unlocked_units`, but unlocked by rmeta.
9091 unlocked_rmeta_units : Vec < Unit > ,
9192 /// Individual compilation section durations, gathered from `--json=timings`.
92- sections : HashMap < String , TimingSection > ,
93+ sections : HashMap < String , CompilationSection > ,
9394}
9495
9596impl UnitTime {
@@ -315,6 +316,7 @@ impl<'gctx> Timings<'gctx> {
315316 mode : unit_time. unit . mode ,
316317 duration : unit_time. duration ,
317318 rmeta_time : unit_time. rmeta_time ,
319+ sections : unit_time. sections . clone ( ) ,
318320 }
319321 . to_json_string ( ) ;
320322 crate :: drop_println!( self . gctx, "{}" , msg) ;
@@ -723,20 +725,20 @@ impl UnitTime {
723725 . sections
724726 . insert (
725727 name. to_string ( ) ,
726- TimingSection {
728+ CompilationSection {
727729 start : now - self . start ,
728730 end : None ,
729731 } ,
730732 )
731733 . is_some ( )
732734 {
733- warn ! ( "Compilation section {name} started more than once" ) ;
735+ warn ! ( "compilation section {name} started more than once" ) ;
734736 }
735737 }
736738
737739 fn end_section ( & mut self , name : & str , now : f64 ) {
738740 let Some ( section) = self . sections . get_mut ( name) else {
739- warn ! ( "Compilation section {name} ended, but it has no start recorded" ) ;
741+ warn ! ( "compilation section {name} ended, but it has no start recorded" ) ;
740742 return ;
741743 } ;
742744 section. end = Some ( now - self . start ) ;
0 commit comments