Skip to content

Commit 048866b

Browse files
authored
Rollup merge of #76958 - est31:ns, r=oli-obk
Replace manual as_nanos and as_secs_f64 reimplementations
2 parents b670b86 + 43193dc commit 048866b

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

compiler/rustc_codegen_llvm/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn compile_codegen_unit(
108108

109109
// We assume that the cost to run LLVM on a CGU is proportional to
110110
// the time we needed for codegenning it.
111-
let cost = time_to_codegen.as_secs() * 1_000_000_000 + time_to_codegen.subsec_nanos() as u64;
111+
let cost = time_to_codegen.as_nanos() as u64;
112112

113113
fn module_codegen(tcx: TyCtxt<'_>, cgu_name: Symbol) -> ModuleCodegen<ModuleLlvm> {
114114
let cgu = tcx.codegen_unit(cgu_name);

compiler/rustc_data_structures/src/profiling.rs

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

609606
// Memory reporting

library/test/src/bench.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ fn fmt_thousands_sep(mut n: usize, sep: char) -> String {
9898
output
9999
}
100100

101-
fn ns_from_dur(dur: Duration) -> u64 {
102-
dur.as_secs() * 1_000_000_000 + (dur.subsec_nanos() as u64)
103-
}
104-
105101
fn ns_iter_inner<T, F>(inner: &mut F, k: u64) -> u64
106102
where
107103
F: FnMut() -> T,
@@ -110,7 +106,7 @@ where
110106
for _ in 0..k {
111107
black_box(inner());
112108
}
113-
ns_from_dur(start.elapsed())
109+
start.elapsed().as_nanos() as u64
114110
}
115111

116112
pub fn iter<T, F>(inner: &mut F) -> stats::Summary

0 commit comments

Comments
 (0)