Open YuyuZha0 opened 1 year ago
I get similar results (RE2 is 3x slower):
Benchmark Mode Cnt Score Error Units
Re2Benchmark.wholeWordsEndingWithNn_jdk thrpt 5 4.496 ± 0.292 ops/s
Re2Benchmark.wholeWordsEndingWithNn_re2 thrpt 5 1.582 ± 0.124 ops/s
Note: I tested on sample (16MB book) from https://github.com/rust-leipzig/regex-performance and pattern \b\w+nn\b
for which RE2 excels in their benchmark.
On the other hand, RE2 is tremendously faster for regex with 100 alternations (first names) on the same sample, which is consistent with https://github.com/google/re2j#why-should-i-switch:
Benchmark Mode Cnt Score Error Units
Re2Benchmark.manyAlternation_jdk thrpt 5 0.278 ± 0.002 ops/s
Re2Benchmark.manyAlternations_re2 thrpt 5 111.601 ± 0.324 ops/s
Note: length of input text also matters
Here is my benchmark:
here is the result: