Skip to content

Commit 2143a3f

Browse files
committed
benchmarks for exponent fmt of integers
1 parent 6ba0ce4 commit 2143a3f

File tree

1 file changed

+24
-0
lines changed
  • library/coretests/benches

1 file changed

+24
-0
lines changed

library/coretests/benches/fmt.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,27 @@ fn write_i128_hex(bh: &mut Bencher) {
342342
black_box(&mut buf).clear();
343343
});
344344
}
345+
346+
#[bench]
347+
fn write_i64_exp(bh: &mut Bencher) {
348+
let mut buf = String::with_capacity(1024);
349+
bh.iter(|| {
350+
write!(black_box(&mut buf), "{:e}", black_box(0_i64)).unwrap();
351+
write!(black_box(&mut buf), "{:e}", black_box(100_i64)).unwrap();
352+
write!(black_box(&mut buf), "{:e}", black_box(-100_i64)).unwrap();
353+
write!(black_box(&mut buf), "{:e}", black_box(1_i64 << 32)).unwrap();
354+
black_box(&mut buf).clear();
355+
});
356+
}
357+
358+
#[bench]
359+
fn write_i128_exp(bh: &mut Bencher) {
360+
let mut buf = String::with_capacity(1024);
361+
bh.iter(|| {
362+
write!(black_box(&mut buf), "{:e}", black_box(0_i128)).unwrap();
363+
write!(black_box(&mut buf), "{:e}", black_box(100_i128)).unwrap();
364+
write!(black_box(&mut buf), "{:e}", black_box(-100_i128)).unwrap();
365+
write!(black_box(&mut buf), "{:e}", black_box(1_i128 << 64)).unwrap();
366+
black_box(&mut buf).clear();
367+
});
368+
}

0 commit comments

Comments
 (0)