Skip to content

Commit 8bfae2d

Browse files
committed
Make timings optional.
1 parent da07061 commit 8bfae2d

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct JobQueue<'a, 'cfg> {
4040
is_release: bool,
4141
progress: Progress<'cfg>,
4242
next_id: u32,
43-
timings: Timings<'a, 'cfg>,
43+
timings: Option<Timings<'a, 'cfg>>,
4444
}
4545

4646
pub struct JobState<'a> {
@@ -133,7 +133,10 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
133133
pub fn new(bcx: &BuildContext<'a, 'cfg>, root_units: &[Unit<'a>]) -> JobQueue<'a, 'cfg> {
134134
let (tx, rx) = channel();
135135
let progress = Progress::with_style("Building", ProgressStyle::Ratio, bcx.config);
136-
let timings = Timings::new(bcx, root_units);
136+
let timings = match bcx.config.cli_unstable().timings {
137+
Some(..) => Some(Timings::new(bcx, root_units)),
138+
None => None,
139+
};
137140
JobQueue {
138141
queue: DependencyQueue::new(),
139142
tx,
@@ -320,8 +323,9 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
320323
// to the jobserver itself.
321324
tokens.truncate(self.active.len() - 1);
322325

323-
self.timings
324-
.mark_concurrency(self.active.len(), queue.len(), self.queue.len());
326+
if let Some(t) = &mut self.timings {
327+
t.mark_concurrency(self.active.len(), queue.len(), self.queue.len());
328+
}
325329

326330
// Drain all events at once to avoid displaying the progress bar
327331
// unnecessarily.
@@ -340,7 +344,9 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
340344
.config
341345
.shell()
342346
.verbose(|c| c.status("Running", &cmd))?;
343-
self.timings.unit_start(id, self.active[&id]);
347+
if let Some(t) = &mut self.timings {
348+
t.unit_start(id, self.active[&id]);
349+
}
344350
}
345351
Message::BuildPlanMsg(module_name, cmd, filenames) => {
346352
plan.update(&module_name, &cmd, &filenames)?;
@@ -432,7 +438,9 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
432438
if !cx.bcx.build_config.build_plan {
433439
cx.bcx.config.shell().status("Finished", message)?;
434440
}
435-
self.timings.finished()?;
441+
if let Some(t) = &mut self.timings {
442+
t.finished()?;
443+
}
436444
Ok(())
437445
} else {
438446
debug!("queue: {:#?}", self.queue);
@@ -528,11 +536,15 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
528536

529537
match fresh {
530538
Freshness::Fresh => {
531-
self.timings.add_fresh();
539+
if let Some(t) = &mut self.timings {
540+
t.add_fresh();
541+
}
532542
doit()
533543
}
534544
Freshness::Dirty => {
535-
self.timings.add_dirty();
545+
if let Some(t) = &mut self.timings {
546+
t.add_dirty();
547+
}
536548
scope.spawn(move |_| doit());
537549
}
538550
}
@@ -579,9 +591,11 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
579591
self.emit_warnings(None, unit, cx)?;
580592
}
581593
let unlocked = self.queue.finish(unit, &artifact);
582-
match artifact {
583-
Artifact::All => self.timings.unit_finished(id, unlocked),
584-
Artifact::Metadata => self.timings.unit_rmeta_finished(id, unlocked),
594+
if let Some(t) = &mut self.timings {
595+
match artifact {
596+
Artifact::All => t.unit_finished(id, unlocked),
597+
Artifact::Metadata => t.unit_rmeta_finished(id, unlocked),
598+
}
585599
}
586600
Ok(())
587601
}

0 commit comments

Comments
 (0)