Rollup merge of #76958 - est31:ns, r=oli-obk

Replace manual as_nanos and as_secs_f64 reimplementations
This commit is contained in:
Ralf Jung 2020-09-21 10:40:39 +02:00 committed by GitHub
commit 048866bd6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 10 deletions

View file

@ -600,10 +600,7 @@ pub fn print_time_passes_entry(do_it: bool, what: &str, dur: Duration) {
// Hack up our own formatting for the duration to make it easier for scripts
// to parse (always use the same number of decimal places and the same unit).
pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
const NANOS_PER_SEC: f64 = 1_000_000_000.0;
let secs = dur.as_secs() as f64 + dur.subsec_nanos() as f64 / NANOS_PER_SEC;
format!("{:.3}", secs)
format!("{:.3}", dur.as_secs_f64())
}
// Memory reporting