diff options
| author | Ralf Jung <post@ralfj.de> | 2020-09-21 10:40:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-21 10:40:39 +0200 |
| commit | 048866bd6b74ef34a8a2e1a3e89f9617834a5d05 (patch) | |
| tree | b6fbd667abecb8dffbbdf7a00d7429107500dc12 | |
| parent | b670b86353ac42b98a969de6f804f9718a56097d (diff) | |
| parent | 43193dcb882466163436057e50c96bb74d9bf50f (diff) | |
| download | rust-048866bd6b74ef34a8a2e1a3e89f9617834a5d05.tar.gz rust-048866bd6b74ef34a8a2e1a3e89f9617834a5d05.zip | |
Rollup merge of #76958 - est31:ns, r=oli-obk
Replace manual as_nanos and as_secs_f64 reimplementations
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/base.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/profiling.rs | 5 | ||||
| -rw-r--r-- | library/test/src/bench.rs | 6 |
3 files changed, 3 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 6a1b373ef07..f35708b1d09 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -108,7 +108,7 @@ pub fn compile_codegen_unit( // We assume that the cost to run LLVM on a CGU is proportional to // the time we needed for codegenning it. - let cost = time_to_codegen.as_secs() * 1_000_000_000 + time_to_codegen.subsec_nanos() as u64; + let cost = time_to_codegen.as_nanos() as u64; fn module_codegen(tcx: TyCtxt<'_>, cgu_name: Symbol) -> ModuleCodegen<ModuleLlvm> { let cgu = tcx.codegen_unit(cgu_name); diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 07d16c6483e..363879cbb1d 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -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 diff --git a/library/test/src/bench.rs b/library/test/src/bench.rs index e92e5b9829e..b709c763296 100644 --- a/library/test/src/bench.rs +++ b/library/test/src/bench.rs @@ -98,10 +98,6 @@ fn fmt_thousands_sep(mut n: usize, sep: char) -> String { output } -fn ns_from_dur(dur: Duration) -> u64 { - dur.as_secs() * 1_000_000_000 + (dur.subsec_nanos() as u64) -} - fn ns_iter_inner<T, F>(inner: &mut F, k: u64) -> u64 where F: FnMut() -> T, @@ -110,7 +106,7 @@ where for _ in 0..k { black_box(inner()); } - ns_from_dur(start.elapsed()) + start.elapsed().as_nanos() as u64 } pub fn iter<T, F>(inner: &mut F) -> stats::Summary |
