Skip to content

Commit

Permalink
convert the float bneches to use the double function
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Apr 18, 2019
1 parent a3975d0 commit ba928fc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions benches/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,33 @@ fn json_bench(c: &mut Criterion) {

fn recognize_float_bytes(c: &mut Criterion) {
use nom::number::complete::recognize_float;
println!("recognize_float_bytes result: {:?}", recognize_float::<_, (_,ErrorKind)>(&b"-1.234E-12"[..]));
c.bench_function("recognize float bytes", |b| {
b.iter(|| recognize_float::<_, (_,ErrorKind)>(&b"-1.234E-12"[..]));
});
}

fn recognize_float_str(c: &mut Criterion) {
use nom::number::complete::recognize_float;
println!("recognize_float_str result: {:?}", recognize_float::<_, (_,ErrorKind)>("-1.234E-12"));
c.bench_function("recognize float str", |b| {
b.iter(|| recognize_float::<_, (_,ErrorKind)>("-1.234E-12"));
});
}

fn float_bytes(c: &mut Criterion) {
use nom::number::complete::float;
println!("float_bytes result: {:?}", float::<_, (_,ErrorKind)>(&b"-1.234E-12"[..]));
use nom::number::complete::double;
println!("float_bytes result: {:?}", double::<_, (_,ErrorKind)>(&b"-1.234E-12"[..]));
c.bench_function("float bytes", |b| {
b.iter(|| float::<_, (_,ErrorKind)>(&b"-1.234E-12"[..]));
b.iter(|| double::<_, (_,ErrorKind)>(&b"-1.234E-12"[..]));
});
}

fn float_str(c: &mut Criterion) {
use nom::number::complete::float;
println!("float_str result: {:?}", float::<_, (_,ErrorKind)>("-1.234E-12"));
use nom::number::complete::double;
println!("float_str result: {:?}", double::<_, (_,ErrorKind)>("-1.234E-12"));
c.bench_function("float str", |b| {
b.iter(|| float::<_, (_,ErrorKind)>("-1.234E-12"));
b.iter(|| double::<_, (_,ErrorKind)>("-1.234E-12"));
});
}

Expand Down

0 comments on commit ba928fc

Please sign in to comment.