Skip to content

Commit

Permalink
add benchmarks for floats
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Jan 14, 2018
1 parent 87a991f commit 88464c7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions benches/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,27 @@ fn json_bench(b: &mut Bencher) {
//println!("data:\n{:?}", value(&data[..]));
b.iter(|| value(&data[..]));
}

#[bench]
fn recognize_float_bytes(b: &mut Bencher) {
use nom::recognize_float;
b.iter(|| recognize_float(&b"-1.234E-12"[..]));
}

#[bench]
fn recognize_float_str(b: &mut Bencher) {
use nom::recognize_float;
b.iter(|| recognize_float("-1.234E-12"));
}

#[bench]
fn float_bytes(b: &mut Bencher) {
use nom::float;
b.iter(|| float(&b"-1.234E-12"[..]));
}

#[bench]
fn float_str(b: &mut Bencher) {
use nom::float_s;
b.iter(|| float_s("-1.234E-12"));
}

0 comments on commit 88464c7

Please sign in to comment.