Eliminate itoa::write and itoa::fmt from benches
This commit is contained in:
parent
1898210ac6
commit
259ae8a794
|
@ -11,33 +11,17 @@ macro_rules! benches {
|
||||||
$name:ident($value:expr)
|
$name:ident($value:expr)
|
||||||
),*
|
),*
|
||||||
) => {
|
) => {
|
||||||
mod bench_itoa_write {
|
mod bench_itoa_format {
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
$(
|
$(
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
#[bench]
|
#[bench]
|
||||||
fn $name(b: &mut Bencher) {
|
fn $name(b: &mut Bencher) {
|
||||||
let mut buf = Vec::with_capacity(40);
|
let mut buffer = itoa::Buffer::new();
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
buf.clear();
|
let printed = buffer.format(black_box($value));
|
||||||
itoa::write(&mut buf, black_box($value)).unwrap()
|
black_box(printed);
|
||||||
});
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
|
|
||||||
mod bench_itoa_fmt {
|
|
||||||
use test::{Bencher, black_box};
|
|
||||||
$(
|
|
||||||
$(#[$attr])*
|
|
||||||
#[bench]
|
|
||||||
fn $name(b: &mut Bencher) {
|
|
||||||
let mut buf = String::with_capacity(40);
|
|
||||||
|
|
||||||
b.iter(|| {
|
|
||||||
buf.clear();
|
|
||||||
itoa::fmt(&mut buf, black_box($value)).unwrap()
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
@ -55,7 +39,8 @@ macro_rules! benches {
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
buf.clear();
|
buf.clear();
|
||||||
write!(&mut buf, "{}", black_box($value)).unwrap()
|
write!(&mut buf, "{}", black_box($value)).unwrap();
|
||||||
|
black_box(&buf);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
|
Loading…
Reference in New Issue