On Wed, 22 May 2024 14:41:36 GMT, Scott Gibbons <sgibb...@openjdk.org> wrote:
>> test/micro/org/openjdk/bench/java/lang/StringIndexOfHuge.java line 132: >> >>> 130: @Benchmark >>> 131: public int searchHugeLargeSubstring() { >>> 132: return dataStringHuge.indexOf("B".repeat(30) + "X" + >>> "A".repeat(30), 74); >> >> .repeat() call and string concatenation shouldn't be part of the benchmark >> (here and several other @Benchmark functions in this file) since it will >> detract from the measurement. >> >> (String concatenation gets converted (by javac) into >> StringBuilder().append().append()....append().toString()) > > Since we're only concerned with the delta of performance, does this really > matter? Can you suggest an alternative? The needle really should be like the all the other strings, e.g. `dataStringHuge` itself, generated by the setup. As to weather it really matters; the answer is Amdahl's law. You can indeed measure the delta, but you can't measure the speedup of just the indexOf; not with repeat and concatenation obscuring the numbers. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1613864094