On Wed, 15 Mar 2023 18:15:02 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> 
wrote:

> Remove instantiation of `StringBuilder`

Benchmark for the example in the documentation for `Matcher.appendReplacement()`

before

Benchmark                                Mode  Cnt    Score   Error  Units
AppendReplacement.testAppendReplacement  avgt   15  177.029 ± 6.294  ns/op

after

Benchmark                                Mode  Cnt    Score   Error  Units
AppendReplacement.testAppendReplacement  avgt   15  142.373 ± 1.684  ns/op


Same example, but with pattern `"(cat)"` (1 capturing group), matcher on the 
input repeated 1000 times, and replacement string `"$1dog$1cat$1mouse"` (3 back 
references).

before

Benchmark                                Mode  Cnt       Score      Error  Units
AppendReplacement.testAppendReplacement  avgt   15  262576.335 ± 3718.905  ns/op

after

Benchmark                                Mode  Cnt       Score     Error  Units
AppendReplacement.testAppendReplacement  avgt   15  225700.642 ± 683.721  ns/op

-------------

PR: https://git.openjdk.org/jdk/pull/13048

Reply via email to