• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[macro_use]
2 extern crate criterion;
3 
4 #[global_allocator]
5 static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
6 
7 use criterion::Criterion;
8 use nom::number::complete;
9 
parser(i: &[u8]) -> nom::IResult<&[u8], u64>10 fn parser(i: &[u8]) -> nom::IResult<&[u8], u64> {
11   complete::be_u64(i)
12 }
13 
number(c: &mut Criterion)14 fn number(c: &mut Criterion) {
15   let data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
16 
17   parser(&data[..]).expect("should parse correctly");
18   c.bench_function("number", move |b| {
19     b.iter(|| parser(&data[..]).unwrap());
20   });
21 }
22 
23 criterion_group!(benches, number);
24 criterion_main!(benches);
25