From: Aleksey Kladov Date: Sat, 7 Apr 2018 14:12:14 +0000 (+0300) Subject: Try to measure all time it takes to compile code X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~91^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=42304b0f067db29a071de11d73f08438a985bd01;p=cargo.git Try to measure all time it takes to compile code --- diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index cf4c93625..aab373ab2 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -148,8 +148,6 @@ impl<'a> JobQueue<'a> { scope: &Scope<'a>, jobserver_helper: &HelperThread, ) -> CargoResult<()> { - use std::time::Instant; - let mut tokens = Vec::new(); let mut queue = Vec::new(); trace!("queue: {:#?}", self.queue); @@ -165,7 +163,6 @@ impl<'a> JobQueue<'a> { // successful and otherwise wait for pending work to finish if it failed // and then immediately return. let mut error = None; - let start_time = Instant::now(); loop { // Dequeue as much work as we can, learning about everything // possible that can run. Note that this is also the point where we @@ -265,7 +262,7 @@ impl<'a> JobQueue<'a> { if profile.debuginfo.is_some() { opt_type += " + debuginfo"; } - let duration = start_time.elapsed(); + let duration = cx.config.creation_time().elapsed(); let time_elapsed = format!( "{}.{1:.2} secs", duration.as_secs(), diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 19b4312bc..281165ec2 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -11,6 +11,7 @@ use std::mem; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::{Once, ONCE_INIT}; +use std::time::Instant; use curl::easy::Easy; use jobserver; @@ -65,6 +66,7 @@ pub struct Config { easy: LazyCell>, /// Cache of the `SourceId` for crates.io crates_io_source_id: LazyCell, + creation_time: Instant, } impl Config { @@ -101,6 +103,7 @@ impl Config { cli_flags: CliUnstable::default(), easy: LazyCell::new(), crates_io_source_id: LazyCell::new(), + creation_time: Instant::now(), } } @@ -678,6 +681,10 @@ impl Config { { Ok(self.crates_io_source_id.try_borrow_with(f)?.clone()) } + + pub fn creation_time(&self) -> Instant { + self.creation_time + } } #[derive(Eq, PartialEq, Clone, Copy)]