Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace d_as_f64 with as_secs_f64 #8721

Merged
merged 1 commit into from
Sep 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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