summaryrefslogtreecommitdiffstats
path: root/vendor/winnow/examples/arithmetic/bench.rs
blob: 6504454c404c6e6093573cd897d68cc94c875990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
mod parser;

use winnow::prelude::*;

use parser::expr;

#[allow(clippy::eq_op, clippy::erasing_op)]
fn arithmetic(c: &mut criterion::Criterion) {
    let data = "  2*2 / ( 5 - 1) + 3 / 4 * (2 - 7 + 567 *12 /2) + 3*(1+2*( 45 /2));";

    assert_eq!(
        expr.parse_peek(data),
        Ok((";", 2 * 2 / (5 - 1) + 3 * (1 + 2 * (45 / 2)),))
    );
    c.bench_function("arithmetic", |b| {
        b.iter(|| expr.parse_peek(data).unwrap());
    });
}

criterion::criterion_group!(benches, arithmetic);
criterion::criterion_main!(benches);