diff options
| author | Jonas Maier <jonas@x77.dev> | 2026-06-06 10:15:16 +0200 |
|---|---|---|
| committer | Jonas Maier <jonas@x77.dev> | 2026-06-06 10:15:16 +0200 |
| commit | 1ff733a821a947880baaad42aab43a398285418c (patch) | |
| tree | d698de85301a7f9a49f72d0e6dd2ee0a145a7fde /benches | |
| parent | 4eeb79c190bd08e761d097cd10382f09a9ee4348 (diff) | |
| download | pish-1ff733a821a947880baaad42aab43a398285418c.tar.gz | |
regex: benchmark and optimizations
Diffstat (limited to 'benches')
| -rw-r--r-- | benches/regex.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/benches/regex.rs b/benches/regex.rs new file mode 100644 index 0000000..7f20606 --- /dev/null +++ b/benches/regex.rs @@ -0,0 +1,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); |
