Skip to content

Instantly share code, notes, and snippets.

@daschl
Created December 23, 2013 08:01
Show Gist options
  • Save daschl/8093266 to your computer and use it in GitHub Desktop.
Save daschl/8093266 to your computer and use it in GitHub Desktop.
is there a easier way?
package io.netty.jmh.buffer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.buffer.UnpooledByteBufAllocator;
import io.netty.jmh.util.AbstractMicrobenchmark;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
import org.openjdk.jmh.annotations.State;
@State
public class ByteBufAllocatorBenchmark extends AbstractMicrobenchmark {
private final ByteBufAllocator unpooledHeapAllocator = new UnpooledByteBufAllocator(false);
@GenerateMicroBenchmark
public void unpooledHeapAllocAndFree_0() {
ByteBuf buffer = unpooledHeapAllocator.buffer(0);
buffer.release();
}
@GenerateMicroBenchmark
public void unpooledHeapAllocAndFree_256() {
ByteBuf buffer = unpooledHeapAllocator.buffer(256);
buffer.release();
}
@GenerateMicroBenchmark
public void unpooledHeapAllocAndFree_1024() {
ByteBuf buffer = unpooledHeapAllocator.buffer(1024);
buffer.release();
}
@GenerateMicroBenchmark
public void unpooledHeapAllocAndFree_4096() {
ByteBuf buffer = unpooledHeapAllocator.buffer(4096);
buffer.release();
}
@GenerateMicroBenchmark
public void unpooledHeapAllocAndFree_16384() {
ByteBuf buffer = unpooledHeapAllocator.buffer(16384);
buffer.release();
}
@GenerateMicroBenchmark
public void unpooledHeapAllocAndFree_65536() {
ByteBuf buffer = unpooledHeapAllocator.buffer(65536);
buffer.release();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment