Skip to content

Commit

Permalink
Move duration_to_secs_str to rustc_session
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Dec 3, 2019
1 parent 984c74a commit 4351698
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/librustc/util/common.rs
Expand Up @@ -88,15 +88,7 @@ pub fn print_time_passes_entry(do_it: bool, what: &str, dur: Duration) {
what);
}

// 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: 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)
}
pub use rustc_session::utils::duration_to_secs_str;

pub fn to_readable_str(mut val: usize) -> String {
let mut groups = vec![];
Expand Down
1 change: 1 addition & 0 deletions src/librustc_session/lib.rs
@@ -1 +1,2 @@
pub mod cgu_reuse_tracker;
pub mod utils;
9 changes: 9 additions & 0 deletions src/librustc_session/utils.rs
@@ -0,0 +1,9 @@
// 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)
}

0 comments on commit 4351698

Please sign in to comment.