@@ -134,11 +134,33 @@ struct UnitData {
134134
135135impl < ' gctx > Timings < ' gctx > {
136136 pub fn new ( bcx : & BuildContext < ' _ , ' gctx > , root_units : & [ Unit ] ) -> Timings < ' gctx > {
137+ let start = bcx. gctx . creation_time ( ) ;
137138 let has_report = |what| bcx. build_config . timing_outputs . contains ( & what) ;
138139 let report_html = has_report ( TimingOutput :: Html ) ;
139140 let report_json = has_report ( TimingOutput :: Json ) ;
140141 let enabled = report_html | report_json | bcx. logger . is_some ( ) ;
141142
143+ if !enabled {
144+ return Timings {
145+ gctx : bcx. gctx ,
146+ enabled,
147+ report_html,
148+ report_json,
149+ start,
150+ start_str : String :: new ( ) ,
151+ root_targets : Vec :: new ( ) ,
152+ profile : String :: new ( ) ,
153+ total_fresh : 0 ,
154+ total_dirty : 0 ,
155+ unit_times : Vec :: new ( ) ,
156+ active : HashMap :: new ( ) ,
157+ concurrency : Vec :: new ( ) ,
158+ last_cpu_state : None ,
159+ last_cpu_recording : Instant :: now ( ) ,
160+ cpu_usage : Vec :: new ( ) ,
161+ } ;
162+ }
163+
142164 let mut root_map: HashMap < PackageId , Vec < String > > = HashMap :: new ( ) ;
143165 for unit in root_units {
144166 let target_desc = unit. target . description_named ( ) ;
@@ -156,24 +178,20 @@ impl<'gctx> Timings<'gctx> {
156178 . collect ( ) ;
157179 let start_str = jiff:: Timestamp :: now ( ) . to_string ( ) ;
158180 let profile = bcx. build_config . requested_profile . to_string ( ) ;
159- let last_cpu_state = if enabled {
160- match State :: current ( ) {
161- Ok ( state) => Some ( state) ,
162- Err ( e) => {
163- tracing:: info!( "failed to get CPU state, CPU tracking disabled: {:?}" , e) ;
164- None
165- }
181+ let last_cpu_state = match State :: current ( ) {
182+ Ok ( state) => Some ( state) ,
183+ Err ( e) => {
184+ tracing:: info!( "failed to get CPU state, CPU tracking disabled: {:?}" , e) ;
185+ None
166186 }
167- } else {
168- None
169187 } ;
170188
171189 Timings {
172190 gctx : bcx. gctx ,
173191 enabled,
174192 report_html,
175193 report_json,
176- start : bcx . gctx . creation_time ( ) ,
194+ start,
177195 start_str,
178196 root_targets,
179197 profile,
0 commit comments