Permalink
Browse files

Upgrade JMH to 0.4.1 and make use of @Params.

  • Loading branch information...
1 parent 75bb6d0 commit 64be9b2e4a31a1c5a7237ebdf264bd4431e3f602 @daschl daschl committed with normanmaurer Feb 21, 2014
View
@@ -47,7 +47,7 @@
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
- <version>0.3.2</version>
+ <version>0.4.1</version>
</dependency>
</dependencies>
@@ -21,6 +21,7 @@
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 @@
private final ByteBufAllocator pooledHeapAllocator = new PooledByteBufAllocator(false);
private final ByteBufAllocator pooledDirectAllocator = new PooledByteBufAllocator(true);
- @GenerateMicroBenchmark
- public void unpooledHeapAllocAndFree_1_0() {
- ByteBuf buffer = unpooledHeapAllocator.buffer(0);
- buffer.release();
- }
-
- @GenerateMicroBenchmark
- public void unpooledHeapAllocAndFree_2_256() {
- ByteBuf buffer = unpooledHeapAllocator.buffer(256);
- buffer.release();
- }
-
- @GenerateMicroBenchmark
- public void unpooledHeapAllocAndFree_3_1024() {
- ByteBuf buffer = unpooledHeapAllocator.buffer(1024);
- buffer.release();
- }
-
- @GenerateMicroBenchmark
- public void unpooledHeapAllocAndFree_4_4096() {
- ByteBuf buffer = unpooledHeapAllocator.buffer(4096);
- 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();
- }
+ @Param({ "00000", "00256", "01024", "04096", "16384", "65536" })
+ public int size;
@GenerateMicroBenchmark
- public void unpooledDirectAllocAndFree_5_16384() {
- ByteBuf buffer = unpooledDirectAllocator.buffer(16384);
+ public void unpooledHeapAllocAndFree() {
+ ByteBuf buffer = unpooledHeapAllocator.buffer(size);
buffer.release();
}
@GenerateMicroBenchmark
- public void unpooledDirectAllocAndFree_6_65536() {
- ByteBuf buffer = unpooledDirectAllocator.buffer(65536);
+ public void unpooledDirectAllocAndFree() {
+ ByteBuf buffer = unpooledDirectAllocator.buffer(size);
buffer.release();
}
@GenerateMicroBenchmark
- public void pooledHeapAllocAndFree_1_0() {
- ByteBuf buffer = pooledHeapAllocator.buffer(0);
+ public void pooledHeapAllocAndFree() {
+ ByteBuf buffer = pooledHeapAllocator.buffer(size);
buffer.release();
}
@GenerateMicroBenchmark
- public void pooledHeapAllocAndFree_2_256() {
- ByteBuf buffer = pooledHeapAllocator.buffer(256);
+ public void pooledDirectAllocAndFree() {
+ ByteBuf buffer = pooledDirectAllocator.buffer(size);
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();
- }
}
@@ -41,7 +41,7 @@
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[] {

0 comments on commit 64be9b2

Please sign in to comment.