Skip to content

Commit cebbd9f

Browse files
committed
Use as_nanos in bench.rs and base.rs
1 parent 285fc7d commit cebbd9f

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

compiler/rustc_codegen_llvm/src/base.rs

Lines changed: 1 addition & 1 deletion
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);

library/test/src/bench.rs

Lines changed: 1 addition & 5 deletions
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)