From 1ff733a821a947880baaad42aab43a398285418c Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Sat, 6 Jun 2026 10:15:16 +0200 Subject: regex: benchmark and optimizations --- benches/regex.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 benches/regex.rs (limited to 'benches/regex.rs') 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); -- cgit v1.2.3