mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-23 05:10:57 +00:00
add benchmark
This commit is contained in:
parent
967694f69e
commit
8aae88ee06
@ -44,7 +44,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Fork(3)
|
||||
public class Integers {
|
||||
@ -106,13 +106,6 @@ public class Integers {
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void toHexString(Blackhole bh) {
|
||||
for (int i : intsBig) {
|
||||
bh.consume(Integer.toHexString(i));
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs toString on large values, roughly 10 digits. */
|
||||
@Benchmark
|
||||
public void toStringBig(Blackhole bh) {
|
||||
@ -121,6 +114,27 @@ public class Integers {
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void toHexStringTiny(Blackhole bh) {
|
||||
for (int i : intsTiny) {
|
||||
bh.consume(Integer.toHexString(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void toHexStringSmall(Blackhole bh) {
|
||||
for (int i : intsSmall) {
|
||||
bh.consume(Integer.toHexString(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void toHexStringBig(Blackhole bh) {
|
||||
for (int i : intsBig) {
|
||||
bh.consume(Integer.toHexString(i));
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs expand on small values */
|
||||
@Benchmark
|
||||
public void expand(Blackhole bh) {
|
||||
|
||||
@ -87,17 +87,23 @@ public class Longs {
|
||||
|
||||
/** Performs toString on large values, around 10 digits. */
|
||||
@Benchmark
|
||||
public void toHexString(Blackhole bh) {
|
||||
public void toStringBig(Blackhole bh) {
|
||||
for (long value : longArrayBig) {
|
||||
bh.consume(Long.toString(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void toHexStringSmall(Blackhole bh) {
|
||||
for (long value : longArraySmall) {
|
||||
bh.consume(Long.toHexString(value));
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs toString on large values, around 10 digits. */
|
||||
@Benchmark
|
||||
public void toStringBig(Blackhole bh) {
|
||||
public void toHexStringBig(Blackhole bh) {
|
||||
for (long value : longArrayBig) {
|
||||
bh.consume(Long.toString(value));
|
||||
bh.consume(Long.toHexString(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user