mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8334397: RISC-V: verify perf of ReverseBytesS/US
Reviewed-by: fyang, luhenry
This commit is contained in:
parent
75a2afacc8
commit
cae94b268d
4 changed files with 98 additions and 31 deletions
|
@ -35,6 +35,7 @@ import org.openjdk.jmh.annotations.Setup;
|
|||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.Warmup;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
|
@ -48,6 +49,29 @@ public class Characters {
|
|||
@Param({"9", "65", "97", "223", "430"})
|
||||
private int codePoint;
|
||||
|
||||
@Param("500")
|
||||
private int size;
|
||||
|
||||
private char[] chars;
|
||||
private char[] res;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
Random r = new Random(0);
|
||||
chars = new char[size];
|
||||
res = new char[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
chars[i] = (char)r.nextInt(Character.MAX_VALUE + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void reverseBytes() {
|
||||
for (int i = 0; i < size; i++) {
|
||||
res[i] = Character.reverseBytes(chars[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public boolean isDigit() {
|
||||
return Character.isDigit(codePoint);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue