diff --git a/Cargo.toml b/Cargo.toml
index 4d74afd..066b7ad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,6 @@ version = "0.4.0"
include = ["src/**/*", "LICENSE", "README.md", "benches"]
[dev-dependencies]
-criterion = "0.3.5"
pretty_assertions = "1.0.0"
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.71"
@@ -20,6 +19,7 @@ test-generator = "0.3.0"
serde_bytes = "0.11.5"
glob = "0.3.0"
libtest-mimic = "0.3.0"
+iai = "0.1.1"
[features]
# By default this crate depends on the jetscii library for best performance.
@@ -35,7 +35,7 @@ integration-tests = []
jetscii = { version = "0.5.1", optional = true }
[[bench]]
-name = "data_state"
+name = "patterns"
harness = false
[[test]]
diff --git a/benches/data_state.rs b/benches/data_state.rs
deleted file mode 100644
index 39d02f2..0000000
--- a/benches/data_state.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
-use html5gum::Tokenizer;
-
-fn data_state(c: &mut Criterion) {
- for i in [100, 1000, 10000, 1000000] {
- let s: String = (0..i).map(|_| 'a').collect();
- c.bench_with_input(BenchmarkId::new("aaa", i), &s, |b, s| {
- b.iter(|| for _ in Tokenizer::new(s).infallible() {})
- });
- }
-}
-
-criterion_group!(benches, data_state);
-criterion_main!(benches);
diff --git a/benches/patterns.rs b/benches/patterns.rs
new file mode 100644
index 0000000..2e4344a
--- /dev/null
+++ b/benches/patterns.rs
@@ -0,0 +1,31 @@
+use iai::{black_box, main};
+
+use html5gum::Tokenizer;
+
+fn pattern(pattern: &str, i: usize) {
+ let s: String = black_box((0..i).map(|_| pattern).collect());
+ for _ in Tokenizer::new(&s).infallible() {}
+}
+
+macro_rules! pattern_tests {
+ ($(($name:ident, $pattern:expr, $repeat:expr), )*) => {
+ $(
+ fn $name() {
+ pattern($pattern, $repeat)
+ }
+ )*
+
+ main!($($name),*);
+ }
+}
+
+pattern_tests![
+ (data_state_10, "a", 10),
+ (data_state_10000, "a", 10000),
+ (tagopen_10, "", 10),
+ (tagopen_10000, "", 10000),
+ (tagopenclose_10, "", 10),
+ (tagopenclose_10000, "", 10000),
+ (comment_10, "", 10),
+ (comment_10000, "", 10000),
+];