RFR: 8278518: String(byte[], int, int, Charset) constructor and String.translateEscapes() miss bounds check elimination [v2]
Сергей Цыпанов
duke at openjdk.java.net
Wed Jan 12 12:15:28 UTC 2022
On Wed, 12 Jan 2022 10:24:45 GMT, Roland Westrelin <roland at openjdk.org> wrote:
>> Good. Can you add JMH benchmark for this case?
>
>> 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();
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/7034
More information about the hotspot-compiler-dev
mailing list