aboutsummaryrefslogtreecommitdiffstats
path: root/benches/regex.rs
blob: 7f20606b37f3463424fe8d6c6ae61e0de476628d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use criterion::{Criterion, criterion_group, criterion_main};
use pish::parse::{
    Parse,
    regex::{Pattern, bc::BytecodeCompiledRegex},
};

/// https://mattmahoney.net/dc/enwik8.zip
pub fn regex_throughput(c: &mut Criterion) {
    let mut content = std::fs::read("enwik8").unwrap();
    content.truncate(1_000_000);
    let pat = Pattern::parse_from_bytes(b".*GNU.plus.Linux.*").unwrap();
    let compiled = BytecodeCompiledRegex::try_from(pat).unwrap();

    c.bench_function("enwik8 match-all", |b| {
        b.iter(|| {
            let _ = compiled.re_match(&content);
        })
    });
}

criterion_group!(benches, regex_throughput);
criterion_main!(benches);