8288732: Reduce runtime of java.util.concurrent microbenchmarks

Reviewed-by: ecaspole, rriggs
This commit is contained in:
Claes Redestad 2022-08-05 14:35:45 +00:00
parent 88c96dd3eb
commit 0da4314e95
12 changed files with 198 additions and 102 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,13 +24,16 @@ package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OperationsPerInvocation;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.TimeUnit;
@ -42,6 +45,9 @@ import java.util.concurrent.atomic.AtomicReference;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class Atomic {
public AtomicInteger aInteger;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,14 @@ package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -43,6 +46,9 @@ import java.util.function.IntUnaryOperator;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class AtomicIntegerUpdateAndGet {
private PaddedAtomicInteger count;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,15 @@
package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
@ -43,6 +46,9 @@ import java.util.concurrent.TimeUnit;
*/
@OutputTimeUnit(TimeUnit.MINUTES)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(3)
public class ForkJoinPoolForking {
/**
@ -56,58 +62,63 @@ public class ForkJoinPoolForking {
* FJP could be faster than baseline, because the baseline is single-threaded.
*/
@Param("0")
private int workers;
@Param("10000000")
private int size;
@Param("10")
private int threshold;
/** Encapsulate all the state depended on only by actual test. This avoids running baselines for every parameter value. */
@State(Scope.Benchmark)
public static class TestState {
@Param("0")
private int workers;
@Param({"1", "2", "3", "4", "5", "6", "7", "8"})
private int threshold;
private ForkJoinPool fjpSync;
private ForkJoinPool fjpAsync;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
fjpSync = new ForkJoinPool(workers, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, false);
fjpAsync = new ForkJoinPool(workers, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
}
@TearDown
public void teardown() {
fjpSync.shutdownNow();
fjpAsync.shutdownNow();
}
}
private Problem problem;
private ForkJoinPool fjpSync;
private ForkJoinPool fjpAsync;
@Setup
public void setup() {
problem = new Problem(size);
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
fjpSync = new ForkJoinPool(workers, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, false);
fjpAsync = new ForkJoinPool(workers, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
}
@TearDown
public void teardown() {
fjpSync.shutdownNow();
fjpAsync.shutdownNow();
}
@Benchmark
public long baselineRaw() {
return problem.solve();
public Long testExplicit_Sync(TestState state) throws ExecutionException, InterruptedException {
return state.fjpSync.invoke(new ExplicitTask(problem, 0, problem.size(), state.threshold));
}
@Benchmark
public Long testExplicit_Sync() throws ExecutionException, InterruptedException {
return fjpSync.invoke(new ExplicitTask(problem, 0, problem.size(), threshold));
public Long testExplicit_Async(TestState state) throws ExecutionException, InterruptedException {
return state.fjpAsync.invoke(new ExplicitTask(problem, 0, problem.size(), state.threshold));
}
@Benchmark
public Long testExplicit_Async() throws ExecutionException, InterruptedException {
return fjpAsync.invoke(new ExplicitTask(problem, 0, problem.size(), threshold));
public Long testStandard_Sync(TestState state) throws ExecutionException, InterruptedException {
return state.fjpSync.invoke(new StandardTask(problem, 0, problem.size(), state.threshold));
}
@Benchmark
public Long testStandard_Sync() throws ExecutionException, InterruptedException {
return fjpSync.invoke(new StandardTask(problem, 0, problem.size(), threshold));
}
@Benchmark
public Long testStandard_Async() throws ExecutionException, InterruptedException {
return fjpAsync.invoke(new StandardTask(problem, 0, problem.size(), threshold));
public Long testStandard_Async(TestState state) throws ExecutionException, InterruptedException {
return state.fjpAsync.invoke(new StandardTask(problem, 0, problem.size(), state.threshold));
}
private static class ExplicitTask extends RecursiveTask<Long> {
@ -173,6 +184,4 @@ public class ForkJoinPoolForking {
return res;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,15 @@
package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import java.util.ArrayList;
import java.util.List;
@ -48,6 +51,9 @@ import java.util.concurrent.TimeUnit;
*/
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(3)
public class ForkJoinPoolRawCallable {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,15 @@
package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
@ -41,6 +44,9 @@ import java.util.concurrent.TimeUnit;
*/
@OutputTimeUnit(TimeUnit.MINUTES)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(3)
public class ForkJoinPoolThresholdAutoQueued {
/**
@ -54,31 +60,40 @@ public class ForkJoinPoolThresholdAutoQueued {
* versus sequential version.
*/
@Param("0")
private int workers;
@Param("10000000")
private int size;
@Param({"1", "2", "3", "4", "5", "6", "7", "8"})
private int threshold;
/** Encapsulate all the state depended on only by actual test. This avoids running baselines for every parameter value. */
@State(Scope.Benchmark)
public static class TestState {
@Param("0")
private int workers;
@Param({"1", "2", "3", "4", "5", "6", "7", "8"})
private int threshold;
private ForkJoinPool fjp;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
fjp = new ForkJoinPool(workers);
}
@TearDown
public void teardown() {
fjp.shutdownNow();
}
}
private ForkJoinPool fjp;
private Problem problem;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
problem = new Problem(size);
fjp = new ForkJoinPool(workers);
}
@TearDown
public void teardown() {
fjp.shutdownNow();
}
@Benchmark
@ -87,8 +102,8 @@ public class ForkJoinPoolThresholdAutoQueued {
}
@Benchmark
public Long test() throws ExecutionException, InterruptedException {
return fjp.invoke(new AutoQueuedTask(threshold, problem, 0, problem.size()));
public Long test(TestState state) throws ExecutionException, InterruptedException {
return state.fjp.invoke(new AutoQueuedTask(state.threshold, problem, 0, problem.size()));
}
private static class AutoQueuedTask extends RecursiveTask<Long> {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,15 @@
package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
@ -41,6 +44,9 @@ import java.util.concurrent.TimeUnit;
*/
@OutputTimeUnit(TimeUnit.MINUTES)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(3)
public class ForkJoinPoolThresholdAutoSurplus {
/**
@ -54,31 +60,40 @@ public class ForkJoinPoolThresholdAutoSurplus {
* versus sequential version.
*/
@Param("0")
private int workers;
@Param("10000000")
private int size;
@Param({"1", "2", "3", "4", "5", "6", "7", "8"})
private int threshold;
/** Encapsulate all the state depended on only by actual test. This avoids running baselines for every parameter value. */
@State(Scope.Benchmark)
public static class TestState {
@Param("0")
private int workers;
@Param({"1", "2", "3", "4", "5", "6", "7", "8"})
private int threshold;
private ForkJoinPool fjp;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
fjp = new ForkJoinPool(workers);
}
@TearDown
public void teardown() {
fjp.shutdownNow();
}
}
private ForkJoinPool fjp;
private Problem problem;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
problem = new Problem(size);
fjp = new ForkJoinPool(workers);
}
@TearDown
public void teardown() {
fjp.shutdownNow();
}
@Benchmark
@ -87,8 +102,8 @@ public class ForkJoinPoolThresholdAutoSurplus {
}
@Benchmark
public Long test() throws ExecutionException, InterruptedException {
return fjp.invoke(new AutoQueuedTask(threshold, problem, 0, problem.size()));
public Long test(TestState state) throws ExecutionException, InterruptedException {
return state.fjp.invoke(new AutoQueuedTask(state.threshold, problem, 0, problem.size()));
}
private static class AutoQueuedTask extends RecursiveTask<Long> {
@ -122,7 +137,4 @@ public class ForkJoinPoolThresholdAutoSurplus {
return res;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,15 @@
package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
@ -41,6 +44,9 @@ import java.util.concurrent.TimeUnit;
*/
@OutputTimeUnit(TimeUnit.MINUTES)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 2)
@Measurement(iterations = 5, time = 2)
@Fork(3)
public class ForkJoinPoolThresholdStatic {
/**
@ -56,31 +62,40 @@ public class ForkJoinPoolThresholdStatic {
* versus sequential version.
*/
@Param("0")
private int workers;
@Param("10000000")
private int size;
@Param({"1", "5", "10", "50", "100", "500", "1000", "5000", "10000", "50000", "100000", "500000", "1000000", "5000000", "10000000"})
private int threshold;
/** Encapsulate all the state depended on only by actual test. This avoids running baselines for every parameter value. */
@State(Scope.Benchmark)
public static class TestState {
@Param("0")
private int workers;
@Param({"1", "5", "10", "100", "1000", "10000", "100000", "1000000", "10000000"})
private int threshold;
private ForkJoinPool fjp;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
fjp = new ForkJoinPool(workers);
}
@TearDown
public void teardown() {
fjp.shutdownNow();
}
}
private ForkJoinPool fjp;
private Problem problem;
@Setup
public void setup() {
if (workers == 0) {
workers = Runtime.getRuntime().availableProcessors();
}
problem = new Problem(size);
fjp = new ForkJoinPool(workers);
}
@TearDown
public void teardown() {
fjp.shutdownNow();
}
@Benchmark
@ -89,8 +104,8 @@ public class ForkJoinPoolThresholdStatic {
}
@Benchmark
public Long test() throws ExecutionException, InterruptedException {
return fjp.invoke(new AdjustableThreshTask(threshold, problem, 0, problem.size()));
public Long test(TestState state) throws ExecutionException, InterruptedException {
return state.fjp.invoke(new AdjustableThreshTask(state.threshold, problem, 0, problem.size()));
}
private static class AdjustableThreshTask extends RecursiveTask<Long> {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,14 @@ package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import java.io.IOException;
@ -44,6 +47,9 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class Locks {
private ReentrantLock reentrantLock;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,12 +24,15 @@ package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -39,6 +42,9 @@ import java.util.concurrent.atomic.AtomicLong;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class Maps {
private SimpleRandom rng;
private Map<Integer, Integer> map;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,8 @@ package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
@ -31,6 +33,7 @@ import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.ArrayBlockingQueue;
@ -47,6 +50,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class ProducerConsumer {
@Param("100")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,12 +24,15 @@ package org.openjdk.bench.java.util.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.ArrayBlockingQueue;
@ -41,6 +44,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class Queues {
@Param("100")

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,9 @@ import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(3)
public class ThreadLocalRandomNextInt {
@State(Scope.Benchmark)