Benchmark for itoa::fmt
This commit is contained in:
parent
ef180dc6e7
commit
c7c3caf3b9
|
@ -15,7 +15,7 @@ macro_rules! benches {
|
||||||
$name:ident($value:expr)
|
$name:ident($value:expr)
|
||||||
),*
|
),*
|
||||||
) => {
|
) => {
|
||||||
mod bench_itoa {
|
mod bench_itoa_write {
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
$(
|
$(
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
|
@ -33,7 +33,25 @@ macro_rules! benches {
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
mod bench_fmt {
|
mod bench_itoa_fmt {
|
||||||
|
use test::{Bencher, black_box};
|
||||||
|
$(
|
||||||
|
$(#[$attr])*
|
||||||
|
#[bench]
|
||||||
|
fn $name(b: &mut Bencher) {
|
||||||
|
use itoa;
|
||||||
|
|
||||||
|
let mut buf = String::with_capacity(40);
|
||||||
|
|
||||||
|
b.iter(|| {
|
||||||
|
buf.clear();
|
||||||
|
itoa::fmt(&mut buf, black_box($value)).unwrap()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
|
mod bench_std_fmt {
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
$(
|
$(
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
|
|
Loading…
Reference in New Issue