Skip to content

Commit

Permalink
Auto merge of #8721 - est31:ns, r=ehuss
Browse files Browse the repository at this point in the history
Replace d_as_f64 with as_secs_f64
  • Loading branch information
bors committed Sep 20, 2020
2 parents d8c8548 + 1b81285 commit 13b73cd
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/cargo/core/compiler/timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl<'cfg> Timings<'cfg> {
let unit_time = UnitTime {
unit,
target,
start: d_as_f64(self.start.elapsed()),
start: self.start.elapsed().as_secs_f64(),
duration: 0.0,
rmeta_time: None,
unlocked_units: Vec::new(),
Expand All @@ -200,7 +200,7 @@ impl<'cfg> Timings<'cfg> {
Some(ut) => ut,
None => return,
};
let t = d_as_f64(self.start.elapsed());
let t = self.start.elapsed().as_secs_f64();
unit_time.rmeta_time = Some(t - unit_time.start);
assert!(unit_time.unlocked_rmeta_units.is_empty());
unit_time
Expand All @@ -218,7 +218,7 @@ impl<'cfg> Timings<'cfg> {
Some(ut) => ut,
None => return,
};
let t = d_as_f64(self.start.elapsed());
let t = self.start.elapsed().as_secs_f64();
unit_time.duration = t - unit_time.start;
assert!(unit_time.unlocked_units.is_empty());
unit_time
Expand Down Expand Up @@ -262,7 +262,7 @@ impl<'cfg> Timings<'cfg> {
return;
}
let c = Concurrency {
t: d_as_f64(self.start.elapsed()),
t: self.start.elapsed().as_secs_f64(),
active,
waiting,
inactive,
Expand Down Expand Up @@ -305,7 +305,7 @@ impl<'cfg> Timings<'cfg> {
let pct_idle = current.idle_since(prev);
*prev = current;
self.last_cpu_recording = now;
let dur = d_as_f64(now.duration_since(self.start));
let dur = now.duration_since(self.start).as_secs_f64();
self.cpu_usage.push((dur, 100.0 - pct_idle));
}

Expand Down Expand Up @@ -334,7 +334,7 @@ impl<'cfg> Timings<'cfg> {
bcx: &BuildContext<'_, '_>,
error: &Option<anyhow::Error>,
) -> CargoResult<()> {
let duration = d_as_f64(self.start.elapsed());
let duration = self.start.elapsed().as_secs_f64();
let timestamp = self.start_str.replace(&['-', ':'][..], "");
let filename = format!("cargo-timing-{}.html", timestamp);
let mut f = BufWriter::new(paths::create(&filename)?);
Expand Down Expand Up @@ -616,11 +616,6 @@ impl UnitTime {
}
}

// Replace with as_secs_f64 when 1.38 hits stable.
fn d_as_f64(d: Duration) -> f64 {
(d.as_secs() as f64) + f64::from(d.subsec_nanos()) / 1_000_000_000.0
}

fn render_rustc_info(bcx: &BuildContext<'_, '_>) -> String {
let version = bcx
.rustc()
Expand Down

0 comments on commit 13b73cd

Please sign in to comment.