aboutsummaryrefslogtreecommitdiffstats
path: root/benches/regex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'benches/regex.rs')
-rw-r--r--benches/regex.rs22
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);