RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination [v2]
Vladimir Kozlov
kvn at openjdk.java.net
Wed Jan 12 19:22:28 UTC 2022
On Wed, 12 Jan 2022 12:12:33 GMT, Сергей Цыпанов <duke at openjdk.java.net> wrote:
>>> Good. Can you add JMH benchmark for this case?
>>
>> Thanks for the review.
>> I'm not the author of the benchmark. That actually came up in another PR where a library fix was discussed:
>> https://github.com/openjdk/jdk/pull/6812
>> Shouldn't the benchmark's author (that is @stsypanov or @amirhadadi) submit it (and sign the OCA if required)?
>
> @rwestrel The benchmark is mine and OCA is signed. Here's the code
>
> @State(Scope.Thread)
> @BenchmarkMode(Mode.AverageTime)
> @OutputTimeUnit(TimeUnit.NANOSECONDS)
> public class StringConstructorBenchmark {
> private byte[] array;
> private String str;
>
> @Setup
> public void setup() {
> str = "Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen. Я";//Latin1 ending with Russian
> array = str.getBytes(StandardCharsets.UTF_8);
> }
>
> @Benchmark
> public String newString() {
> return new String(array, 0, array.length, StandardCharsets.UTF_8);
> }
>
> @Benchmark
> public String translateEscapes() {
> return str.translateEscapes();
> }
> }
Thank you, @stsypanov for clarifying status of your benchmark.
@amirhadadi I agree that to have simple benchmark is good. But I also want to add Sergey's benchmark because it shows the issue in this bug description. I suggest to add both benchmarks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7034
More information about the hotspot-compiler-dev
mailing list