#![feature(test)]
extern crate test;
extern crate nom_lua;
use test::Bencher;
use nom_lua::number;
#[bench]
fn parse_hex_int(b: &mut Bencher) {
let ints: Vec<String> =
test::black_box((0..32)
.map(|i| format!("0x{:X}", i).to_string())
.collect());
b.iter(|| {
for i in &ints {
number::parse_number(i.as_bytes());
}
});
}
#[bench]
fn parse_int(b: &mut Bencher) {
let ints: Vec<String> =
test::black_box((0..32)
.map(|i| format!("{}", i).to_string())
.collect());
b.iter(|| {
for i in &ints {
number::parse_number(i.as_bytes());
}
});
}
#[bench]
fn parse_float(b: &mut Bencher) {
let ints: Vec<String> =
test::black_box((0..32)
.map(|i| format!("{}", i as f32).to_string())
.collect());
b.iter(|| {
for i in &ints {
number::parse_number(i.as_bytes());
}
});
}