mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8278831: Use table lookup for the last two bytes in Integer.getChars
Reviewed-by: jlaskey, rriggs
This commit is contained in:
parent
431bd9a66d
commit
71ca85f5a6
4 changed files with 26 additions and 31 deletions
|
@ -53,17 +53,20 @@ public class Integers {
|
|||
private int size;
|
||||
|
||||
private String[] strings;
|
||||
private int[] intsTiny;
|
||||
private int[] intsSmall;
|
||||
private int[] intsBig;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
Random r = new Random(0);
|
||||
strings = new String[size];
|
||||
Random r = new Random(0);
|
||||
strings = new String[size];
|
||||
intsTiny = new int[size];
|
||||
intsSmall = new int[size];
|
||||
intsBig = new int[size];
|
||||
intsBig = new int[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
strings[i] = "" + (r.nextInt(10000) - (5000));
|
||||
intsTiny[i] = r.nextInt(99);
|
||||
intsSmall[i] = 100 * i + i + 103;
|
||||
intsBig[i] = ((100 * i + i) << 24) + 4543 + i * 4;
|
||||
}
|
||||
|
@ -91,6 +94,14 @@ public class Integers {
|
|||
}
|
||||
}
|
||||
|
||||
/** Performs toString on very small values, just one or two digits. */
|
||||
@Benchmark
|
||||
public void toStringTiny(Blackhole bh) {
|
||||
for (int i : intsTiny) {
|
||||
bh.consume(Integer.toString(i));
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs toString on large values, roughly 10 digits. */
|
||||
@Benchmark
|
||||
public void toStringBig(Blackhole bh) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue