@@ -13,7 +13,6 @@ use std::error::Report;
13
13
use std:: io:: { self , Write } ;
14
14
use std:: path:: Path ;
15
15
use std:: sync:: { Arc , Mutex } ;
16
- use std:: time:: Instant ;
17
16
use std:: vec;
18
17
19
18
use derive_setters:: Setters ;
@@ -29,10 +28,10 @@ use termcolor::{ColorSpec, WriteColor};
29
28
use crate :: diagnostic:: IsLint ;
30
29
use crate :: emitter:: {
31
30
ColorConfig , Destination , Emitter , HumanEmitter , HumanReadableErrorType , OutputTheme ,
32
- TimingSectionKind , should_show_source_code,
31
+ TimingEvent , should_show_source_code,
33
32
} ;
34
33
use crate :: registry:: Registry ;
35
- use crate :: timings:: TimingSection ;
34
+ use crate :: timings:: { TimingRecord , TimingSection } ;
36
35
use crate :: translation:: { Translate , to_fluent_args} ;
37
36
use crate :: {
38
37
CodeSuggestion , FluentBundle , LazyFallbackBundle , MultiSpan , SpanLabel , Subdiag , Suggestions ,
@@ -62,8 +61,6 @@ pub struct JsonEmitter {
62
61
macro_backtrace : bool ,
63
62
track_diagnostics : bool ,
64
63
terminal_url : TerminalUrl ,
65
- #[ setters( skip) ]
66
- start_timestamp : Instant ,
67
64
}
68
65
69
66
impl JsonEmitter {
@@ -89,7 +86,6 @@ impl JsonEmitter {
89
86
macro_backtrace : false ,
90
87
track_diagnostics : false ,
91
88
terminal_url : TerminalUrl :: No ,
92
- start_timestamp : Instant :: now ( ) ,
93
89
}
94
90
}
95
91
@@ -109,7 +105,7 @@ impl JsonEmitter {
109
105
enum EmitTyped < ' a > {
110
106
Diagnostic ( Diagnostic ) ,
111
107
Artifact ( ArtifactNotification < ' a > ) ,
112
- SectionTimestamp ( SectionTimestamp < ' a > ) ,
108
+ SectionTiming ( SectionTimestamp < ' a > ) ,
113
109
FutureIncompat ( FutureIncompatReport < ' a > ) ,
114
110
UnusedExtern ( UnusedExterns < ' a > ) ,
115
111
}
@@ -141,21 +137,16 @@ impl Emitter for JsonEmitter {
141
137
}
142
138
}
143
139
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" ,
148
144
} ;
149
- let name = match section {
145
+ let name = match record . section {
150
146
TimingSection :: Linking => "link" ,
151
147
} ;
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) ) ;
159
150
if let Err ( e) = result {
160
151
panic ! ( "failed to print timing section: {e:?}" ) ;
161
152
}
@@ -294,8 +285,8 @@ struct SectionTimestamp<'a> {
294
285
/// Name of the section
295
286
name : & ' a str ,
296
287
/// 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 .
299
290
timestamp : u128 ,
300
291
}
301
292
0 commit comments