summaryrefslogtreecommitdiffstats
path: root/vendor/anes/benches/benchmarks/parser.rs
blob: 2aa63aaa7729a8fbffd9efea8f40c59aaefd2430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use criterion::{black_box, criterion_group, Criterion};

use anes::parser::Parser;

pub fn parser(c: &mut Criterion) {
    const XTERM_MOUSE: &str = "\x1B[<28;20;10;m";

    let mut parser = Parser::default();

    c.bench_function("advance and consume", |b| {
        let input = XTERM_MOUSE.as_bytes();

        b.iter(|| {
            parser.advance(black_box(input), black_box(true));
            while let Some(_) = parser.next() {}
        })
    });
}

criterion_group!(benches, parser);