8314085: Fixing scope from benchmark to thread for JMH tests having shared state
Co-authored-by: Vladimir Ivanov <vaivanov@openjdk.org> Reviewed-by: sviswanathan, ecaspole
This commit is contained in:
parent
ae796a4e10
commit
b438cffdb9
@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Fork(value = 4, warmups = 0)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Warmup(iterations = 2, time = 2)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class DataInputStreamTest {
|
||||
private final int size = 1024;
|
||||
|
||||
|
@ -46,7 +46,7 @@ import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||
@Warmup(iterations = 2, time = 3, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 15, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(1)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class ArrayClone {
|
||||
|
||||
@Param({"0", "10", "100", "1000"})
|
||||
|
@ -51,7 +51,7 @@ import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Measurement(iterations = 3, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Warmup(iterations = 3, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Fork(3)
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(3)
|
||||
|
@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 3)
|
||||
|
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 3)
|
||||
|
@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 3)
|
||||
|
@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 3)
|
||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Fork(value = 3)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class StringSubstring {
|
||||
|
||||
public String s = new String("An arbitrary string that happened to be of length 52");
|
||||
|
@ -42,7 +42,7 @@ import static java.util.FormatProcessor.FMT;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 3, jvmArgsAppend = "--enable-preview")
|
||||
|
@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Warmup(iterations = 3, time = 2)
|
||||
@Measurement(iterations = 6, time = 1)
|
||||
@Fork(1)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class MethodTypeDescFactories {
|
||||
|
||||
private static final ClassDesc DUMMY_CD = ClassDesc.of("Dummy_invalid");
|
||||
|
@ -47,7 +47,7 @@ import static java.lang.constant.ConstantDescs.*;
|
||||
@Warmup(iterations = 3, time = 2)
|
||||
@Measurement(iterations = 6, time = 1)
|
||||
@Fork(1)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class ReferenceClassDescResolve {
|
||||
private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
|
||||
private static final ClassDesc CLASS_OR_INTERFACE = CD_String;
|
||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Fork(3)
|
||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/sun.security.ssl=ALL-UNNAMED", "--add-opens", "java.base/sun.security.ssl=ALL-UNNAMED"})
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
|
@ -58,7 +58,7 @@ import org.openjdk.jmh.infra.Blackhole;
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(3)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class GetYearBench {
|
||||
|
||||
private TimeZone UTC = TimeZone.getTimeZone("UTC");
|
||||
|
@ -50,7 +50,7 @@ import org.openjdk.jmh.annotations.Warmup;
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(3)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class InstantBench {
|
||||
|
||||
private Instant[] INSTANTS;
|
||||
|
@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(3)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class DateTimeFormatterWithPaddingBench {
|
||||
|
||||
private static final DateTimeFormatter FORMATTER_WITH_PADDING = new DateTimeFormatterBuilder()
|
||||
|
@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* initializers. Use parallel GC and set initial heap size to avoid
|
||||
* GC during runs.
|
||||
*/
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@Fork(value = 3, jvmArgsAppend = { "-verbose:gc", "-XX:+UseParallelGC", "-Xms4g", "-Xmx4g", "-Xint" })
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
|
@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 4, time = 2)
|
||||
@Measurement(iterations = 4, time = 2)
|
||||
@Fork(value = 3)
|
||||
|
@ -29,7 +29,7 @@ import org.openjdk.jmh.annotations.*;
|
||||
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class TestAdler32 {
|
||||
|
||||
private Adler32 adler32;
|
||||
|
@ -29,7 +29,7 @@ import org.openjdk.jmh.annotations.*;
|
||||
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 4, time = 2)
|
||||
@Measurement(iterations = 4, time = 2)
|
||||
@Fork(value = 3)
|
||||
|
@ -29,7 +29,7 @@ import org.openjdk.jmh.annotations.*;
|
||||
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 4, time = 2)
|
||||
@Measurement(iterations = 4, time = 2)
|
||||
@Fork(value = 3)
|
||||
|
@ -47,7 +47,7 @@ import java.util.regex.Pattern;
|
||||
@Fork(2)
|
||||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class Exponential {
|
||||
/** Run length of non-matching consecutive whitespace chars. */
|
||||
@Param({"16", "128", "1024"})
|
||||
|
@ -47,7 +47,7 @@ import java.util.regex.Pattern;
|
||||
@Fork(1)
|
||||
@Warmup(iterations = 2, time = 3, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 4, time = 3, timeUnit = TimeUnit.SECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class Primality {
|
||||
/** Number to be primality tested. */
|
||||
@Param({"16", "17", /* "256", "257", */ "4096", "4099"})
|
||||
|
@ -78,7 +78,7 @@ import java.util.regex.Pattern;
|
||||
@Fork(2)
|
||||
@Warmup(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class Trim {
|
||||
/** Run length of non-matching consecutive whitespace chars. */
|
||||
@Param({"16", "256", "4096"})
|
||||
|
@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@Fork(value = 3, jvmArgsAppend = {"-Xms1g", "-Xmx1g"})
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
public class AESReinit {
|
||||
|
||||
private Cipher cipher;
|
||||
|
@ -29,7 +29,7 @@ import org.openjdk.jmh.annotations.*;
|
||||
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 3, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
|
||||
|
@ -41,7 +41,7 @@ import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Fork(value = 3)
|
||||
@Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
|
@ -28,7 +28,7 @@ import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Fork(value = 3, jvmArgsAppend = "-XX:-UseSuperWord")
|
||||
@Warmup(time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
|
@ -28,16 +28,16 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
||||
@State(Scope.Benchmark)
|
||||
@State(Scope.Thread)
|
||||
@Warmup(iterations = 5, time = 1)
|
||||
@Measurement(iterations = 5, time = 1)
|
||||
@Fork(value = 1, jvmArgsAppend = {"-XX:-UseSuperWord"})
|
||||
public class ConvertF2I {
|
||||
static final int LENGTH = 1000;
|
||||
static final int[] INT_ARRAY = new int[LENGTH];
|
||||
static final long[] LONG_ARRAY = new long[LENGTH];
|
||||
static final float[] FLOAT_ARRAY = new float[LENGTH];
|
||||
static final double[] DOUBLE_ARRAY = new double[LENGTH];
|
||||
int[] intArray = new int[LENGTH];
|
||||
long[] longArray = new long[LENGTH];
|
||||
float[] floatArray = new float[LENGTH];
|
||||
double[] doubleArray = new double[LENGTH];
|
||||
float f;
|
||||
double d;
|
||||
|
||||
@ -64,28 +64,28 @@ public class ConvertF2I {
|
||||
@Benchmark
|
||||
public void f2iArray() {
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
INT_ARRAY[i] = (int)FLOAT_ARRAY[i];
|
||||
intArray[i] = (int)floatArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void f2lArray() {
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
LONG_ARRAY[i] = (long)FLOAT_ARRAY[i];
|
||||
longArray[i] = (long)floatArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void d2iArray() {
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
INT_ARRAY[i] = (int)DOUBLE_ARRAY[i];
|
||||
intArray[i] = (int)doubleArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void d2lArray() {
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
LONG_ARRAY[i] = (long)DOUBLE_ARRAY[i];
|
||||
longArray[i] = (long)doubleArray[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user