diff --git a/microbench/pom.xml b/microbench/pom.xml index 229771ceb5..cdf7a0e9be 100644 --- a/microbench/pom.xml +++ b/microbench/pom.xml @@ -47,7 +47,7 @@ org.openjdk.jmh jmh-core - 0.3.2 + 0.4.1 diff --git a/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java b/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java index a5ecf6d6b0..5e2030aad6 100644 --- a/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java +++ b/microbench/src/test/java/io/netty/microbench/buffer/ByteBufAllocatorBenchmark.java @@ -21,6 +21,7 @@ import io.netty.buffer.PooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.microbench.util.AbstractMicrobenchmark; import org.openjdk.jmh.annotations.GenerateMicroBenchmark; +import org.openjdk.jmh.annotations.Param; /** * This class benchmarks different allocators with different allocation sizes. @@ -32,147 +33,31 @@ public class ByteBufAllocatorBenchmark extends AbstractMicrobenchmark { private final ByteBufAllocator pooledHeapAllocator = new PooledByteBufAllocator(false); private final ByteBufAllocator pooledDirectAllocator = new PooledByteBufAllocator(true); + @Param({ "00000", "00256", "01024", "04096", "16384", "65536" }) + public int size; + @GenerateMicroBenchmark - public void unpooledHeapAllocAndFree_1_0() { - ByteBuf buffer = unpooledHeapAllocator.buffer(0); + public void unpooledHeapAllocAndFree() { + ByteBuf buffer = unpooledHeapAllocator.buffer(size); buffer.release(); } @GenerateMicroBenchmark - public void unpooledHeapAllocAndFree_2_256() { - ByteBuf buffer = unpooledHeapAllocator.buffer(256); + public void unpooledDirectAllocAndFree() { + ByteBuf buffer = unpooledDirectAllocator.buffer(size); buffer.release(); } @GenerateMicroBenchmark - public void unpooledHeapAllocAndFree_3_1024() { - ByteBuf buffer = unpooledHeapAllocator.buffer(1024); + public void pooledHeapAllocAndFree() { + ByteBuf buffer = pooledHeapAllocator.buffer(size); buffer.release(); } @GenerateMicroBenchmark - public void unpooledHeapAllocAndFree_4_4096() { - ByteBuf buffer = unpooledHeapAllocator.buffer(4096); + public void pooledDirectAllocAndFree() { + ByteBuf buffer = pooledDirectAllocator.buffer(size); buffer.release(); } - @GenerateMicroBenchmark - public void unpooledHeapAllocAndFree_5_16384() { - ByteBuf buffer = unpooledHeapAllocator.buffer(16384); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledHeapAllocAndFree_6_65536() { - ByteBuf buffer = unpooledHeapAllocator.buffer(65536); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledDirectAllocAndFree_1_0() { - ByteBuf buffer = unpooledDirectAllocator.buffer(0); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledDirectAllocAndFree_2_256() { - ByteBuf buffer = unpooledDirectAllocator.buffer(256); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledDirectAllocAndFree_3_1024() { - ByteBuf buffer = unpooledDirectAllocator.buffer(1024); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledDirectAllocAndFree_4_4096() { - ByteBuf buffer = unpooledDirectAllocator.buffer(4096); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledDirectAllocAndFree_5_16384() { - ByteBuf buffer = unpooledDirectAllocator.buffer(16384); - buffer.release(); - } - - @GenerateMicroBenchmark - public void unpooledDirectAllocAndFree_6_65536() { - ByteBuf buffer = unpooledDirectAllocator.buffer(65536); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledHeapAllocAndFree_1_0() { - ByteBuf buffer = pooledHeapAllocator.buffer(0); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledHeapAllocAndFree_2_256() { - ByteBuf buffer = pooledHeapAllocator.buffer(256); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledHeapAllocAndFree_3_1024() { - ByteBuf buffer = pooledHeapAllocator.buffer(1024); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledHeapAllocAndFree_4_4096() { - ByteBuf buffer = pooledHeapAllocator.buffer(4096); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledHeapAllocAndFree_5_16384() { - ByteBuf buffer = pooledHeapAllocator.buffer(16384); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledHeapAllocAndFree_6_65536() { - ByteBuf buffer = pooledHeapAllocator.buffer(65536); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledDirectAllocAndFree_1_0() { - ByteBuf buffer = pooledDirectAllocator.buffer(0); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledDirectAllocAndFree_2_256() { - ByteBuf buffer = pooledDirectAllocator.buffer(256); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledDirectAllocAndFree_3_1024() { - ByteBuf buffer = pooledDirectAllocator.buffer(1024); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledDirectAllocAndFree_4_4096() { - ByteBuf buffer = pooledDirectAllocator.buffer(4096); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledDirectAllocAndFree_5_16384() { - ByteBuf buffer = pooledDirectAllocator.buffer(16384); - buffer.release(); - } - - @GenerateMicroBenchmark - public void pooledDirectAllocAndFree_6_65536() { - ByteBuf buffer = pooledDirectAllocator.buffer(65536); - buffer.release(); - } } diff --git a/microbench/src/test/java/io/netty/microbench/util/AbstractMicrobenchmark.java b/microbench/src/test/java/io/netty/microbench/util/AbstractMicrobenchmark.java index 1ef42f64f6..b2357621a8 100644 --- a/microbench/src/test/java/io/netty/microbench/util/AbstractMicrobenchmark.java +++ b/microbench/src/test/java/io/netty/microbench/util/AbstractMicrobenchmark.java @@ -41,7 +41,7 @@ import java.io.File; public class AbstractMicrobenchmark { protected static final int DEFAULT_WARMUP_ITERATIONS = 10; - protected static final int DEFAULT_MEASURE_ITERATIONS = 1; + protected static final int DEFAULT_MEASURE_ITERATIONS = 10; protected static final int DEFAULT_FORKS = 2; protected static final String[] JVM_ARGS = new String[] {