Aho-Corasick benchmarks
Latest stable Based on Text release 0.2.1
The 0.2.1 baseline records JMH throughput snapshots for large dictionaries, dense matches, no-match text, Flow collection, a naive small-dictionary comparison, and NFKC normalization. Higher ops/s is better.
Recorded environment
Section titled “Recorded environment”| Item | Value |
|---|---|
| command | ./gradlew :text-search:benchmark |
| host | Apple M4 Pro, 48 GiB memory |
| JVM | GraalVM JDK 21.0.11 |
| mode | throughput, 1 thread, 1 fork |
| warmup | 2 × 1 second |
| measurement | 5 × 1 second |
Baseline results
Section titled “Baseline results”| Benchmark | Ops/s | What it exercises |
|---|---|---|
parseTextNoMatch | 12,209.23 | 5,000-keyword automaton with no matches |
parseTextDenseMatches | 3,566.90 | dense overlapping candidate matches |
parseTextLargeDictionary | 3,116.99 | 5,000 keywords and 2,000 matched tokens |
matchesAsFlowLargeDictionaryCollect | 712.62 | Flow collection over the large dictionary input |
naiveContainsSmallDictionary | 248.39 | sequential String.contains over 1,000 keywords |
parseTextNfkcNormalization | 3.68 | NFKC and case-insensitive normalization path |
The NFKC result demonstrates why normalization should be an explicit requirement rather than a default applied without measurement. It is not directly comparable to the raw no-match case as an algorithm ranking because the work differs.
Interpret correctly
Section titled “Interpret correctly”These values are local comparable snapshots, not production rankings. Compare a later result only when benchmark source, fixture sizes, command, JDK, hardware class, forks, warmup, measurement, and ops/s direction remain compatible.
The naive small-dictionary case is a reference workload, not proof that every application gains the same factor. Construction cost and memory are outside these throughput values; measure them separately when automatons change frequently.
Re-run
Section titled “Re-run”./gradlew :text-search:benchmarkKeep the raw JSON. Report the score and error range, explain material fixture changes, and avoid merging values from different environments into one trend line.
Choose an API with evidence
Section titled “Choose an API with evidence”Use regular search methods for immediate in-memory results. Use Flow for pipeline and cancellation semantics, understanding that the recorded collection path has additional overhead. Enable normalization only for a demonstrated Unicode equivalence requirement.
Continue with the Text search module, search example, and startup and memory.