@@ -64,8 +64,9 @@ pub struct Timings<'gctx> {
64
64
cpu_usage : Vec < ( f64 , f64 ) > ,
65
65
}
66
66
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 {
69
70
/// Start of the section, as an offset in seconds from `UnitTime::start`.
70
71
start : f64 ,
71
72
/// End of the section, as an offset in seconds from `UnitTime::start`.
@@ -89,7 +90,7 @@ struct UnitTime {
89
90
/// Same as `unlocked_units`, but unlocked by rmeta.
90
91
unlocked_rmeta_units : Vec < Unit > ,
91
92
/// Individual compilation section durations, gathered from `--json=timings`.
92
- sections : HashMap < String , TimingSection > ,
93
+ sections : HashMap < String , CompilationSection > ,
93
94
}
94
95
95
96
impl UnitTime {
@@ -315,6 +316,7 @@ impl<'gctx> Timings<'gctx> {
315
316
mode : unit_time. unit . mode ,
316
317
duration : unit_time. duration ,
317
318
rmeta_time : unit_time. rmeta_time ,
319
+ sections : unit_time. sections . clone ( ) ,
318
320
}
319
321
. to_json_string ( ) ;
320
322
crate :: drop_println!( self . gctx, "{}" , msg) ;
@@ -723,20 +725,20 @@ impl UnitTime {
723
725
. sections
724
726
. insert (
725
727
name. to_string ( ) ,
726
- TimingSection {
728
+ CompilationSection {
727
729
start : now - self . start ,
728
730
end : None ,
729
731
} ,
730
732
)
731
733
. is_some ( )
732
734
{
733
- warn ! ( "Compilation section {name} started more than once" ) ;
735
+ warn ! ( "compilation section {name} started more than once" ) ;
734
736
}
735
737
}
736
738
737
739
fn end_section ( & mut self , name : & str , now : f64 ) {
738
740
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" ) ;
740
742
return ;
741
743
} ;
742
744
section. end = Some ( now - self . start ) ;
0 commit comments