@@ -13,7 +13,6 @@ use std::error::Report;
1313use std:: io:: { self , Write } ;
1414use std:: path:: Path ;
1515use std:: sync:: { Arc , Mutex } ;
16- use std:: time:: Instant ;
1716use std:: vec;
1817
1918use derive_setters:: Setters ;
@@ -29,10 +28,10 @@ use termcolor::{ColorSpec, WriteColor};
2928use crate :: diagnostic:: IsLint ;
3029use crate :: emitter:: {
3130 ColorConfig , Destination , Emitter , HumanEmitter , HumanReadableErrorType , OutputTheme ,
32- TimingSectionKind , should_show_source_code,
31+ TimingEvent , should_show_source_code,
3332} ;
3433use crate :: registry:: Registry ;
35- use crate :: timings:: TimingSection ;
34+ use crate :: timings:: { TimingRecord , TimingSection } ;
3635use crate :: translation:: { Translate , to_fluent_args} ;
3736use crate :: {
3837 CodeSuggestion , FluentBundle , LazyFallbackBundle , MultiSpan , SpanLabel , Subdiag , Suggestions ,
@@ -62,8 +61,6 @@ pub struct JsonEmitter {
6261 macro_backtrace : bool ,
6362 track_diagnostics : bool ,
6463 terminal_url : TerminalUrl ,
65- #[ setters( skip) ]
66- start_timestamp : Instant ,
6764}
6865
6966impl JsonEmitter {
@@ -89,7 +86,6 @@ impl JsonEmitter {
8986 macro_backtrace : false ,
9087 track_diagnostics : false ,
9188 terminal_url : TerminalUrl :: No ,
92- start_timestamp : Instant :: now ( ) ,
9389 }
9490 }
9591
@@ -109,7 +105,7 @@ impl JsonEmitter {
109105enum EmitTyped < ' a > {
110106 Diagnostic ( Diagnostic ) ,
111107 Artifact ( ArtifactNotification < ' a > ) ,
112- SectionTimestamp ( SectionTimestamp < ' a > ) ,
108+ SectionTiming ( SectionTimestamp < ' a > ) ,
113109 FutureIncompat ( FutureIncompatReport < ' a > ) ,
114110 UnusedExtern ( UnusedExterns < ' a > ) ,
115111}
@@ -141,21 +137,16 @@ impl Emitter for JsonEmitter {
141137 }
142138 }
143139
144- fn emit_timing_section ( & mut self , section : TimingSection , kind : TimingSectionKind ) {
145- let kind = match kind {
146- TimingSectionKind :: Start => "start" ,
147- TimingSectionKind :: End => "end" ,
140+ fn emit_timing_section ( & mut self , record : TimingRecord , event : TimingEvent ) {
141+ let event = match event {
142+ TimingEvent :: Start => "start" ,
143+ TimingEvent :: End => "end" ,
148144 } ;
149- let name = match section {
145+ let name = match record . section {
150146 TimingSection :: Linking => "link" ,
151147 } ;
152- let time = Instant :: now ( ) ;
153- let data = SectionTimestamp {
154- name,
155- kind,
156- timestamp : time. duration_since ( self . start_timestamp ) . as_micros ( ) ,
157- } ;
158- let result = self . emit ( EmitTyped :: SectionTimestamp ( data) ) ;
148+ let data = SectionTimestamp { name, event, timestamp : record. timestamp } ;
149+ let result = self . emit ( EmitTyped :: SectionTiming ( data) ) ;
159150 if let Err ( e) = result {
160151 panic ! ( "failed to print timing section: {e:?}" ) ;
161152 }
@@ -294,8 +285,8 @@ struct SectionTimestamp<'a> {
294285 /// Name of the section
295286 name : & ' a str ,
296287 /// Start/end of the section
297- kind : & ' a str ,
298- /// Microseconds elapsed since some predetermined point in time (~start of the rustc process) .
288+ event : & ' a str ,
289+ /// Opaque timestamp .
299290 timestamp : u128 ,
300291}
301292
0 commit comments